Skip to main content
cancel
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

Reply
proj_ss
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.

 

ReportPage.png

 

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 🙂 

Shyam.S

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
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

 

Regards,

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

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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