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

Show last n month by category and date with 0 instead of blank

Hello,

 

I created a measure to get the amount of the previous month with the last date selected in a slicer .

If i want  to show 4 last month by level i get this

 

Levelaout 2022sept 2022oct 2022nov 2022
Level 12324652
Level 245807646754
....    
 
With this measure - > Last n month =
var y=MAX(DateTable[Date])
return CALCULATE([Amount],DATESBETWEEN(Datetable[Date],EOMONTH(y,-12),y))
 
I want to return 0 if "Last n month" return blank by adding 0 in the measure  but when I do this, the filter does not work anymore and i get this :

 

Levelmai 2022juin 2022juil 2022aout 2022sept 2022oct 2022nov 2022
Level 10002324652
Level 200045807646754
....       
How can i do to get 0 and make the filter "DATEBETWEEN" work?
Thank you

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Datavizuserpbi Try:

 Last n month =
var y=MAX(DateTable[Date])
return CALCULATE([Amount],DATESBETWEEN(Datetable[Date],EOMONTH(y,-12),y)) + 0

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hello, I tried but it's not working 

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.