Forum Discussion
4 Years MAT calculation with YOY change
- 4 years ago
Hi enghone09 ,
From the example you've provided as far as I understand you need to achieve this:
Measures:
MATvalue = VAR currentYear = MAX ( 'Date'[Year] ) VAR latestDay = DAY ( MAXX ( ALL ( T6[Date] ), T6[Date] ) ) VAR latestMonth = MONTH ( MAXX ( ALL ( T6[Date] ), T6[Date] ) ) VAR MATDate = DATE ( currentYear, latestMonth, latestDay ) VAR firstDay = EDATE ( MATDate + 1, -12 ) RETURN CALCULATE ( SUM ( T6[No. of Services] ), 'Date'[Date] >= firstDay, 'Date'[Date] <= MATDate )To have correct totals:
MATresult = IF ( HASONEVALUE ( 'Date'[Year] ), [MATvalue], SUMX ( VALUES ( 'Date'[Year] ), [MATvalue] ) )MAT%:
MAT% = VAR currentValue = [MATvalue] VAR previousValue = CALCULATE ( [MATvalue], DATEADD ( 'Date'[Date], -1, YEAR ) ) RETURN IF ( HASONEVALUE ( 'Date'[Year] ), DIVIDE ( currentValue - previousValue, previousValue ), BLANK () )If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.
enghone09 , Not very clear, but something like with YTD
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"7/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"7/31"))
Last 2 Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"7/31"))
3rd Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"7/31"))
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
- enghone094 years agoFrequent Visitor
Hi amitchandak ,
Thank you for your response. I have attached my sample data.
- How can I change the above dax formula to be dynamic without having to change the date from "7/31" to "8/31" once the data become available?
- Is there a DAX formula that can calculate all 3 years in one measure?