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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Show previous month rows based on slicer

I want to make a table that lets me see all the rows corresponding to a previous month based on a slicer. For example, if I click the slicer on September, I want the table to show every row corresponding to August.

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , Do you have Date. If Yes, then you can use time intelligence. If not create separate a month year table with Rank and use that. Refer to my blog

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

Example of measures

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Next month value =  CALCULATE(sum(''Table''[total hours value]),nextmonth('Date'[Date]))
Next to next  month value =  CALCULATE(sum(''Table''[total hours value]),nextmonth(dateadd('Date'[Date],1,MONTH)))
previous to previous month value =  CALCULATE(sum(''Table''[total hours value]),previousmonth(dateadd('Date'[Date],-1,MONTH)))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Will this work if a January date is selected? For example, January 2022 is selected will is return Decembers 2021 data for the Month behind Sales measure?

MattAllington
Community Champion
Community Champion

You need a calendar table. https://exceleratorbi.com.au/power-pivot-calendar-tables/
join it to your data table using the date column. Use the month/year columns from your calendar in the slicer.  As you would know, when you click a slicer for Sept, the rows for Sept will show in the visual. This is how it works: the filter on calendar will directly filter your data. You need to manipulate the filter with a measure, so you need a measure that returns a value for the previous month in the visual. The measure will depend on your data, but could look like this

Last Month Data = CALCULATE(countrows(datatable),PREVIOUSMONTH(Calendar[date]))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
Anonymous
Not applicable

I created the Measure, along with te calendar table. I still don´t understand where or how should I use the measure so the filter context based on month changes to the previous of the selected in the slicer. I´m sorry, Im just starting to learn Dax.

You said you want a table to show rows. Add a table visual to the report, add the columns you want to see from the source data table into the table visual. Add the measure into the visual too. Only the rows from the source data from the prior month will show in the table visual. If there is no unique key/ID in the source data table, duplicate rows will be combined, and the measure for that row will be >1



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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