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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
simam
Frequent Visitor

Handling Nulls in Date slicer aggregations

Hi team,

 I have created a measure which calculates the deviation of total value from a target value. The total value can be null sometimes and in this case I would like to see null for the deviation as well. 

here is the measure to calculate the deviation 

IF (SUM('Sawmill Performance Data [Total]) <>BLANK() && sum('Sawmill Performance Data '[Target])<>BLANK() ,divide((sum('Sawmill Performance Data '[Total])-SUM('Sawmill Performance Data '[Target])),SUM('Sawmill Performance Data'[Target])),BLANK())

 

I also have a date slicer in that page. when there is only one date selected, the above formula works correctly, but when for example 2 days is selected where one of the days has null for total but not null for target, then it adds the target of both days and total of both days and calculates the deviation. In this case, the deviation would be off as it shouldn t add the target of the day which the total was null.

 

Business wants to see the nulls as it shows there was no production.  so I cannot just exclude the data where total is null.

I really appreciate if you could help me out. 

2019-09-19_10-28-43.png2019-09-19_10-30-28.png

2 REPLIES 2
Nathaniel_C
Community Champion
Community Champion

Hi @simam ,

Nicely laid out problem!

 

Thinking this through, but close to quitting time, will be thinking about it overnight. Perhaps this post by virtue of going to the top of the pile will be answered by someone else, too. 

 

So, one thought is to do a count of dates, and if more than one, do another test.  This might even be a switch. In which case, test for any null, and don't use the table value for the other, but use null. Thus if Total is null then in the calculation make Target null for that date. (Not changing the table value of course.) 

 

Or instead of a count of dates, wrap this with an if statement to test for Values that make up the Total, and Target, and do the same change to null.

 

Will try to do something with tomorrow.

Hope this  helps,

 

Nathaniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hey @simam , have you come up with anything? You could use BLANK() for AllSelected [Total] and [Target], but I don't see how to iterate through the rows to find that. Could you create a table (based on selected dates) then check the table for values, then replace the values with a null (if the other value is null) and then perform your measue on that table?

 

Or is the solution to step back and go at it from another way?

 

Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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