Forum Discussion
DAX: Show last two months breakdown dynamically
- 6 years ago
Try Below. But you need to have Date table for that
Rolling 2 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date Filer],ENDOFMONTH(Sales[Sales Date]),-2,MONTH))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-functionshttps://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601 - Anonymous6 years ago
amitchandak ha!
I don't know how I got lost in all that complexity in my previous formula but you made me realize that this can be achieved much simpler. Your formula did not work entirely as it was missing an ALL statement at the end and actually the date in the fact table is not needed in the formula, only in the chart itself. But here's the working one:Rolling 2 = CALCULATE([Actual Sales];DATESINPERIOD('DATE_Day'[Date];ENDOFMONTH('DATE_Day'[Date]);-2;MONTH);ALL('DATE_Day'))Thanks for pointing me in the right direction, I was very lost as it seems 😄
Try Below. But you need to have Date table for that
Rolling 2 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date Filer],ENDOFMONTH(Sales[Sales Date]),-2,MONTH))
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/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
- Anonymous6 years agoNot applicable
amitchandak ha!
I don't know how I got lost in all that complexity in my previous formula but you made me realize that this can be achieved much simpler. Your formula did not work entirely as it was missing an ALL statement at the end and actually the date in the fact table is not needed in the formula, only in the chart itself. But here's the working one:Rolling 2 = CALCULATE([Actual Sales];DATESINPERIOD('DATE_Day'[Date];ENDOFMONTH('DATE_Day'[Date]);-2;MONTH);ALL('DATE_Day'))Thanks for pointing me in the right direction, I was very lost as it seems 😄