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
Anonymous
Not applicable

Display data for last 12 months from the selected date even though there is no data

Hi, 

 

I want to display data for the last 12 months from the selected month from the month slicer. 

 

1.PNG

 

In the image I have selected the month 3 in the slicer and the graph displays the data for last 12 months only when there is data. 

Now, on x axis I want all 12 months to be displayed from 03-2020 to 03-2019. 

 

If I select "Show data with no data" then it will display all the months and all the years. It means the month slicer on the top doesn't work. 

2.PNG

 

I have attached the PBIX, can anyone help me please. Please find the PBIX 

 

Thank you

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to change your original two measures to these:

LTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<=[Max Ref Pick Date],CALCULATE([LTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

MTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<=[Max Ref Pick Date],CALCULATE([MTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

Then apply filters to original visual:

33.PNG

The result shows:

32.PNG

Here is the changed pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

3 REPLIES 3
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to change your original two measures to these:

LTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<=[Max Ref Pick Date],CALCULATE([LTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

MTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<=[Max Ref Pick Date],CALCULATE([MTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

Then apply filters to original visual:

33.PNG

The result shows:

32.PNG

Here is the changed pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Hi,

 

Sorry, again  am asking a question this solution.

 

If you look at the solution it actually display last 13 months rather than 12. If I tried to change the month count from 12 to 11 in your dax then it display last 11 months not 12. 

Not understanding what's going on. Can you help me?

 

I wanted it to display for last 12 months. 

 

 

Hi,

 

Please try these measures:

LTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<[Max Ref Pick Date],CALCULATE([LTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

MTI 123 = IF(MAX('SMS Incident'[Incident Date])>EDATE([Max Ref Pick Date],-12)&&MAX('SMS Incident'[Incident Date])<[Max Ref Pick Date],CALCULATE([MTI], DATESBETWEEN('SMS Incident'[Incident Date], EDATE([Max Ref Pick Date],-12), [Max Ref Pick Date])),-1)

Hope these can help.

 

Best Regards,

Giotto

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