cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
vsgarciap Regular Visitor
Regular Visitor

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 Contributor
Super Contributor

Re: How to display the 5 previous month

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)
amitchandak Super Contributor
Super Contributor

Re: How to display the 5 previous month

 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
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 321 members 2,850 guests
Please welcome our newest community members: