Forum Discussion
DAX YoY (absolute/percentage) difference
- 6 years ago
Hello @jay5300
Try something like this:
% Change = VAR varThisYear = [Sum of Amount] VAR varLastYear = CALCULATE( [Sum of Amount] , FILTER( ALL('Table1'[FiscalYear]), 'Table1'[FiscalYear] = MAX('Table1'[FiscalYear]) - 1) ) RETURN DIVIDE(varThisYear - varLastYear,varLastYear)Pbix joined.
Anonymous , Can do with time intelligence and date table
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
diff = [MTD Sales]-[last year MTD Sales]
diff % = divide([MTD Sales]-[last year MTD Sales ],[last year MTD Sales])
YTD
YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
- Anonymous6 years agoNot applicable
Hi Amit,
Thanks once again for responding to my query. I have used calculations you provided as reference for creating.
Current year (CY) and Previous Year (PY).
CY= CALCULATE(SUM(Month_Data[Month.CUST_COUNT]),DATESMTD(DATEADD('Dates'[Date], -1, MONTH)))
PY = CALCULATE(SUM(Month_Data[Month.CUST_COUNT]),DATESMTD(DATEADD('Dates'[Date], -13, MONTH)))
diff % = divide([CY]-[PY],[CY])CY and PY fields retrieves the values but yoy is not calculated and is shown as 100%. (please see tbe image for reference).Also, i want the YoY diff % to be calculated for all months where previous year data exists.Is it possible.? can you please guide.?I
- v-diye-msft6 years ago
Community Support
Hello @jay5300
Try something like this:
% Change = VAR varThisYear = [Sum of Amount] VAR varLastYear = CALCULATE( [Sum of Amount] , FILTER( ALL('Table1'[FiscalYear]), 'Table1'[FiscalYear] = MAX('Table1'[FiscalYear]) - 1) ) RETURN DIVIDE(varThisYear - varLastYear,varLastYear)Pbix joined.