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
summer18
Helper III
Helper III

how to show data if measure (aggregated) is null or 0

Hi,

I need help because I have a chart which displays YTD and PY YTD measure.  My first issue is it won't display the data if YTD sales is null so I tried adding +0 in the formula which resulted to displaying the data. But it resulted to another problem which is PY YTD showing null but should have values on it.

 

First screenshot below is correct if using Year as column but I need YOY% so I need to display the format on the 2nd screenshot

correct1.jpg

 

with problem (I need to use this format with YTD and PY):

wrong.jpg

 

Can someone help me on my problems?   

Here is my pbix 

pbix link

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Your first issue can be solved with a new explicit measure

SumSales = 0+sum(data[Sales ])

 The second can be resolved similarly

Prior Year Sales = 0+CALCULATE([SumSales],SAMEPERIODLASTYEAR(CalendarDate[Date]))

Make sure your calendar table has a 1:M relationship.

The YoY% measure can then be written as:

YoY%= divide([SumSales]-[Prior Year Sales],abs([Prior Year Sales]),0)

See attached.

 

View solution in original post

4 REPLIES 4
summer18
Helper III
Helper III

@lbendlin , thank you.  It works

lbendlin
Super User
Super User

Your first issue can be solved with a new explicit measure

SumSales = 0+sum(data[Sales ])

 The second can be resolved similarly

Prior Year Sales = 0+CALCULATE([SumSales],SAMEPERIODLASTYEAR(CalendarDate[Date]))

Make sure your calendar table has a 1:M relationship.

The YoY% measure can then be written as:

YoY%= divide([SumSales]-[Prior Year Sales],abs([Prior Year Sales]),0)

See attached.

 

hi @lbendlin , I tried that but it displays 0 in Prior Year Sales instead of the supposed value:

 

output.jpg

Have you looked at my attached pbix?  There it shows correctly.

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.