Forum Discussion
SAMEPERIODLASTYEAR \ DATESytd for multiply years
Hello
i wish to compare volumes form April 1st to current month (Nov) for the last 5 years.
i can get this to work for the last year using DATESYTD, but i am not able to do the same for the previous years
FYTD Measure 2 = CALCULATE ( sum('FACT - Transactions'[Volume]), DATESYTD ('DIM - Date Table'[Date] , "03/31" ) )
ok, Please change the highlighte part into MIN('DIM - Date Table'[Year]):
FYTD Measure 2 = var var_TodayMonth = MONTH(TODAY()) var var_RelevantYear = IF( var_TodayMonth >= 4 && var_TodayMonth <= 12, MIN('DIM - Date Table'[Year]), MAX('DIM - Date Table'[Year]) ) var var_StartOfCurrentMonth = DATE(var_RelevantYear,var_TodayMonth,1) var var_EndOfLastMonth = var_StartOfCurrentMonth - 1 RETURN CALCULATE( CALCULATE( sum('FACT - Transactions'[Volume]), DATESYTD ('DIM - Date Table'[Date] , "03/31" ) ), 'Dim Date'[Date] = var_EndOfLastMonth )worked on my side
Please also consider how my Date table looks like and that in the measure I used the normal year column (jan - dec) while i used in the table visual the deviated year column (apr mar)
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
27 Replies
- CNENFRNL
Community Champion
= CALCULATE( SUM( 'FACT - Transactions'[Volume] ), DATEADD( DATESYTD( 'DIM - Date Table'[Date], "03/31" ), -2, YEAR ) )- NewbieJono
Post Partisan
would this show two years ago ? would i need to make a measure for each year e.g -3, -4, -5
- CNENFRNL
Community Champion
You can use a slicer for a dynamic comparison between current fy and previous N fy.
- Mikelytics
Resident Rockstar
Hi NewbieJono ,
It would be better to see how you use it in a visual. But based on your measure there might be the problem that the previous years also have values after November which why you get for the previous year values the sum from 1st april until 31. March instead of 31 October.
Can you please elaborate what values of 1st April and 1st November mean for you? Because if your year ends on 31. march then 1st april is the first day of the financial year. Do you work with balances or transactions?
How does your data model look like and what kind of visual do you use? Do you use slicers or do you put the periods in the columns?
Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!
@ me in replies or I'll lose your thread.
- NewbieJono
Post Partisan
we just like to compare from start of financial year to current month, the data is updated once per month and contains previous months data only. so at this point it has data up to October 2022.
i would like to compatare in a table
FY 2018-19 - Apr - Oct
FY 2019-20 - Apr - Oct
FY 2020-21 - Apr - Oct
FY 2021-22 - Apr - Oct
Then in December it would show Apr - Nov for previous years,
sorry i know this seems difficult, i am not able to share the data
- NewbieJono
Post Partisan
i have a date table with FY