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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Advocate I
Advocate I

How to Display last N months Data from a selection of a Month using a filter

Hi, I am required to display the last 4 months data when i select a month from the filter. The problem here is that not all months have data.


Here i have attached my sample dataset and when i filter Segment A it can be seen that i do not have data for certain months.DatasetSample.pngFilteredSegmentA.png


When i select a month from a filterand  if there is no Data for a month, it should skip that month and show the previous month Data but the number of Months should be limited to 4.




For Example say i do not have data for October 2017.  When i choose November 2017, the resulting bar chart should show me November's, September's, August's and July's data (limiting to 4 previous months) instead of November, October, September and August. How do i acheive this?


Thanks in advance 🙂 


Super User
Super User



This looks like a tough one to solve.  Can you share the link from where i can download your PBI file?

Ashish Mathur
Community Support
Community Support

HI @proj_ss,


I'd like to suggest you use relative slicer to choose last n month, then it will display correspond records.

Use a relative date slicer and filter in Power BI Desktop


In addition, you can also take a look at following link about dynamic last n month based on slicer.

Display Last N Months & Selected Month using Single Date Dimension in Power BI



Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft Thanks for the reply, But the management requires that the Filter should be a dropdown and the month that is selected from the filter should display last 3 months of data that is present.


The link you had provided about the last N months displays for the N number of months calender wise, If data is not present for a month it displays the row as blank because data for certain months are not present. 


Is there a way to acheive this?

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors