How to get Quarters for financial year based on date - excel

I'm trying to display quarters based on the financial year: Q1 starting in April, Q2 from July, etc.
In column B there is a list of dates, and in column A I want the corresponding quarter & year. There are 2 parts I can't figure out:
currently for 01 JAN 2018 it shows Q4 2018. Although the date is 2018, it's the final quarter of 2017 and should show Q4 2017
how to get the display format like Q1 17/18 (eg)
At the moment I have:
=CHOOSE(INT((MONTH(B1)-1)/3)+1,"Q4","Q1","Q2","Q3") & " " & YEAR(B1)
Is it possible without any helper columns?

Subtract a Boolean expression from the Year part:
YEAR(B1) - (MONTH(B1)<4)
If the MONTH is Less than 4 it will subtract 1 from the year, otherwise it will subtract 0:
=CHOOSE(INT((MONTH(B1)-1)/3)+1,"Q4","Q1","Q2","Q3") & " " & YEAR(B1) - (MONTH(B1)<4)

Related

Check whether the date range in a certain Month

How to make a formula for a date range is in the certain month?
Eg 1 : 1/1/2021 - 23/3/2021 output will say January 2021 - 31 days, February 2021 - 28 days and March 2021 - 23 days
try:
=ARRAYFORMULA(QUERY(TEXT(SEQUENCE((B1+1)-A1, 1, A1), "mmmm yyyy"),
"select Col1,count(Col1) group by Col1 label count(Col1)''"))
if you need it sorted use:
=INDEX(ARRAY_CONSTRAIN(QUERY(TEXT(SEQUENCE((B1+1)-A1, 1, A1), {"mmmm yyyy", "yyyymm"}),
"select Col1,count(Col1),Col2 group by Col1,Col2 order by Col2 label count(Col1)''"), 9^9, 2))

Excel Formula caculating number days of year between 2 dates

I am looking for an excel formula to calculating the number of days from years between "Start date" & "end date"
Example :
My start date is 06/19/2020
My end date is 06/20/2023
I would to know on this example the number of days from year 2020 => from start date ; year 2021 (full year) ; year 2022 (full year) ; 2023 => from end date
Result :
number of days of 2020 : 195
number of days of 2021 : 365
number of days of 2022 : 365
number of days of 2023 : 170
in my databse i have different start date and end date by line to x year
Thanks for your help
You can simply substract one cell value from another, if for example:
A1 = TODAY() (which returns today's date)
A2 = 1/01/2019
B1 = A1-A2 = 765 days
Hope it was helpful for you
You might be interested in the DATEDIF function:
https://stackoverflow.com/a/73268311/13406526
Sorry, but I'm a newbie, cannot add comments.

Excel - Sum QTD values based on selected month

Desired end state: The QTD field sums the quarterly values to date so as an example for October it would return just the October value (1st month in Q4) but when November is selected as the driver the QTD field would sum Oct + Nov values (ignoring the value for Dec).
I have a spreadsheet with drivers and the current date will be updated daily. This date drives the "Current Month" field from which I want the QTD values to recalculate.
See example linked below. Expected results - Cat 1 QTD for Nov would be 3,387,280; Cat13 QTD for April would be 1,121,021 and so on
Thanks in advance!
In O6:
=SUMIFS(C6:N6,$C$4:$N$4,"<="&MONTH("1 "&A2),$C$4:$N$4,">="&MATCH(INDEX($1:$1,MATCH(MONTH("1 "&A2),$4:$4,0)),$C1:$N1,0))
Alternative approach using SUMPRODUCT:
=SUMPRODUCT(C6:N6,--(("Q"&ROUNDUP(MONTH(1&$A$2)/3,0))=$C$1:$N$1),--($C$4:$N$4<=MONTH(1&$A$2)))
Result:

Excel 2016 calculate fiscal year

Fiscal Year starts July 1 - June 30, I need to calculate and display the number of Fiscal Years between 2 dates.
For example: 01/01/2018-12/31/2018. Result (YYYY-YYYY) should give 2 fiscal years:
2017-2018 (July 1, 2017 - June 30, 2018)
2018-2019 (July 1, 2018 - June 30, 2019)
Its easy to calculate if there are only 2 fiscal years between 2 dates but using =IF(StartDate<DATE(YEAR(StartDate), 7,1),CONCATENATE(YEAR(StartDate)-1, "-", YEAR(StartDate)), CONCATENATE(YEAR(StartDate), "-", YEAR(StartDate)+1)) or
=IF(EndDate<DATE(YEAR(EndDate), 7,1),CONCATENATE(YEAR(EndDate)-1, "-", YEAR(EndDate)), CONCATENATE(YEAR(EndDate), "-", YEAR(EndDate)+1))
But how do I capture if there are more than 2 fiscal years? For example: 01/01/2018 - 09/20/2019
I would prefer the fiscal year be entered in a table range and automatically insert a new row if there are more than 2 fiscal years. I'm looking for either formula or vba solution.
last time i had to do this was for a specific report where the dates are written in cells:
dim s as long, e as long
if month(cells(1,1).value) >= 7 AND day(cells(1,1).value) >= 1 Then
s = year(cells(1,1).value)+1
else
s = year(cells(1,1).value)
end if
if month(cells(2,1).value) >= 7 AND day(cells(1,1).value) >= 1 Then
e = year(cells(1,1).value)+1
else
e = year(cells(1,1).value)
end if
'FY range:
cells(3,1).value = "FY" & s & "-FY" & e
rehashed the code for you, untested

Creating flags for calculating rolling averages in excel

I have a data sheet which looks like:
year month
2017 2017-01
2017 2017-02
2017 2017-03
......
2018 2018-04
2018 2018-05
Note the column month contains text string. I need to create a new column flag in excel which filters which months are to be used in calculating rolling 12M averages for current month and which months are to be used for calculating rolling 12M averages for previous year.
For example today's date is 5/24/2018, so month 2018-05 will be marked as "current". months between 2018-04 to 2017-05 will be marked as "both". month 2017-04 will be marked as "previous". Rest all months will be marked as NA. My final data should look like this:
year month flag
2017 2017-01 NA
2017 2017-02 NA
2017 2017-03 NA
2017 2017-04 Previous
......
2018 2018-04 Both
2018 2018-05 Current
I am having trouble implementing this logic in excel as the column month is a text string and simply using IF condition doesn't works for me. Any leads on this is appreciated.
Edit:
I tried converting the months to a number by using =DATEVALUE(B2 & "-01").
I stored the number for current month in a variable curr.
Now I am using the following formula =IF(B22=curr,"Current", IF(B2=curr-395,"Previous","Both")).
This creates the flag column which I require although there's still an issue based on whether the month has 30 or 31 days. Any solutions for this please?
One way to do it is to use DATDIF.
=DATEVALUE(B2 & "-01") will give you the first of each month in column B.
To return the month number use =DATEDIF(C2,TODAY(),"m") where column C holds the DATEVALUE formula. This will return 0 for this month, 1 for last month... 13 for April 2017.
Now check to see if the count of months = 0 then it's current, if it's greater than 11 it's NA, otherwise it's both. =IF(D2=0,"Current",IF(D2>11,"NA","Both"))
... Edit ....
That's wrong - forgot the "Previous" and "Both" isn't 12 months ....
=IF(D2=0,"Current",IF(D2>13,"NA",IF(D2=13,"Previous","Both")))
As considering your column month format = "YYYY-MM" this code may be helpful
this is Excel function, to use it you need to save this function in the module and use it. `
Function MyDateCal(cell As Range) As String
Dim YearCurrent, YearCell, monthCurrent, MonthCell As Integer
Dim cellVal As String, DiffMonth As Integer[![enter image description here][1]][1]
cellVal = cell.Value
MyDateCal = "NA"
'cellVal = Cells(1, 1).Value
YearCurrent = Year(Now())
monthCurrent = Month(Now())
YearCell = CInt(Left(cellVal, 4))
MonthCell = CInt(Right(cellVal, 2))
DiffMonth = 12 * (YearCurrent - YearCell) + (monthCurrent - MonthCell)
If DiffMonth = 0 Then
MyDateCal = "Current"
ElseIf DiffMonth > 0 And DiffMonth <= 12 Then
MyDateCal = "Both"
ElseIf DiffMonth = 13 Then
MyDateCal = "Previous"
End If
End Function
`

Resources