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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors