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

Division by Zero fix changing visuals

I have a calculation on two measures, SUM('QGenda Compliance'[CompliantClockIn/Out])/SUM('QGenda Compliance'[RequiredClockIn/Out]) resulting in NaN because the denominator can be 0.  I've been trying to fix this with:

Overall Compliance = IF(SUM('QGenda Compliance'[RequiredClockIn/Out])=0,0,SUM('QGenda Compliance'[CompliantClockIn/Out])/SUM('QGenda Compliance'[RequiredClockIn/Out])) which works to get rid of NaN but it has other strange effects.  I have a report with a matrix and some line graphs filtered by a date range of June - September.  When I change this formula these visuals then show the entire date range, say Jan - Dec, but has a 0 for every month except June - September.  Why does it change it to show the entire date range and not just what the user picks on the slider?

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

Hi @Anonymous ,

According to my understand , you want to diaplay the measure result based on Months selected in Slicer , right?

You could use the following formula:

Overall Compliance =
IF (
    'QGenda Compliance'[RequiredClockIn/Out] = 0,
    0,
    'QGenda Compliance'[CompliantClockIn/Out] / 'QGenda Compliance'[RequiredClockIn/Out]
)

Or use DIVIDE()

Overall Compliance =
DIVIDE (
    'QGenda Compliance'[CompliantClockIn/Out],
    'QGenda Compliance'[RequiredClockIn/Out]
)

The matrix visual and line chart look like this:

10.7.1.Division-by-Zero-fix-changing-visuals.gif

 

Here is the pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

View solution in original post

3 REPLIES 3
v-eqin-msft
Community Support
Community Support

Hi @Anonymous ,

According to my understand , you want to diaplay the measure result based on Months selected in Slicer , right?

You could use the following formula:

Overall Compliance =
IF (
    'QGenda Compliance'[RequiredClockIn/Out] = 0,
    0,
    'QGenda Compliance'[CompliantClockIn/Out] / 'QGenda Compliance'[RequiredClockIn/Out]
)

Or use DIVIDE()

Overall Compliance =
DIVIDE (
    'QGenda Compliance'[CompliantClockIn/Out],
    'QGenda Compliance'[RequiredClockIn/Out]
)

The matrix visual and line chart look like this:

10.7.1.Division-by-Zero-fix-changing-visuals.gif

 

Here is the pbix file.

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

ryan_mayu
Super User
Super User

@Anonymous 

have you tried DIVIDE function?

https://docs.microsoft.com/en-us/dax/divide-function-dax

 





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

Proud to be a Super User!




negi007
Community Champion
Community Champion

@Anonymous  Can you use Blank() instead of zero. I hope it works for you

 

IF(SUM('QGenda Compliance'[RequiredClockIn/Out])=0,Blank(),SUM('QGenda Compliance'[CompliantClockIn/Out])/SUM('QGenda Compliance'[RequiredClockIn/Out]))




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



Proud to be a Super User!


Follow me on linkedin

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.