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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How to display the 5 previous month

Hi there,

 

I want to show the 5 previous months and the current one without using a slicer and update it automatically.

 

Data example bellow (assuming that Frebruary is the current month, I want to see the marked months and the current one);

Dax Ex.JPG

 

2 REPLIES 2
amitchandak
Super User
Super User

Try

 

Var   _This_year(max(ENDOFMonth('Date'[Date Filer])) // OR use today
Var   _This_year=today()
Var _min_This_year= (maxx('Date',STARTOMONTH(DATEADD('Date'[Date Filer],-5,MONTH))))


Var   _This_year_val =CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_This_year && (Sales[Sales Date]) >=_min_This_year)

 Or You can also refer https://community.powerbi.com/t5/Desktop/Sum-of-the-amount-of-sales-the-previous-5-months/m-p/808469...


@amitchandak wrote:

Try

 

Var   _This_year(max(ENDOFMonth('Date'[Date Filer])) // OR use today
Var   _This_year=today()
Var _min_This_year= (maxx('Date',STARTOMONTH(DATEADD('Date'[Date Filer],-5,MONTH))))


Var   _This_year_val =CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_This_year && (Sales[Sales Date]) >=_min_This_year)

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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