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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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