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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors