Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Ferha_Jafri
Frequent Visitor

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

1 ACCEPTED SOLUTION
lbendlin
Super User
Super 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.

View solution in original post

2 REPLIES 2
Anonymous
Not 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.

vyangliumsft_2-1724659535143.png

3. Result:

vyangliumsft_3-1724659535147.png

 

 

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

lbendlin
Super User
Super 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.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.