Forum Discussion
How to get Previous Month Year
Hello Experts,
I am new to Power BI, I have a requirement in which I ran a report for prior month, and I want to automate the year. I can easily do as format(today(),"YYYY") but the issue is that next year for Jan 2025, when I will run the report I need 2024 as year. So I want to understand how to automate this. As FYI, I want to use Today() function to make it dynamic as I do not have any date in my data.
Thanks in advance
Ferha
Read about DATEADD() - it allows you to do your shifts by month or by year etc.
It is mandatory that your data model includes a calendar table and that the time intelligence DAX is applied on that table.
2 Replies
- lbendlinSuper User
Read about DATEADD() - it allows you to do your shifts by month or by year etc.
It is mandatory that your data model includes a calendar table and that the time intelligence DAX is applied on that table.
- AnonymousNot applicable
Thanks for the reply from lbendlin , please allow me to provide another insight:
Hi Ferha_Jafri ,Here are the steps you can follow:
1. Create measure.
Flag = var _maxdate= EOMONTH( TODAY(),-1) var _mindate= EOMONTH( TODAY(),-2) return IF( MAX('Table'[Date]) >_mindate&& MAX('Table'[Date])<=_maxdate,1,0)Sum_Measure = SUMX( ALLSELECTED('Table'),[rand])2. Place [Flag]in Filters, set is=1, apply filter.
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly