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

Distinguishing 0/0 values from 0/number values

hello everyone,
i am having a problem of distinguishing a 0/0 or null / null values from a 0/number values on a dashboard as they both shows as an empty cell, i would like to see the 0/2 valuse as a 0 and the null / null or 0/0 values as an empty cells , is there anyway to do that.
thanks .

Hifni93_0-1665061511229.png

 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

See if this works for you (I've created separate measures for the numerator and denominator because it's easier to read, but you can do it all in one measure if you wish)

result.png

 

 

Divide Sales by Target = 
SWITCH(
    TRUE(),
    AND(ISBLANK([Sum Sales]), [Sum Target] >0), 0,
    [Sum Target] >0,
    DIVIDE([Sum Sales], [Sum Target], 0),
    DIVIDE([Sum Sales], [Sum Target]))

 

If you want blank when the target is blank even if there is a value for sales, you can  use this measure:

 

Divide Sales by Target =
SWITCH (
    TRUE (),
    [Sum Target] > 0, DIVIDE ( [Sum Sales], [Sum Target], 0 ),
    DIVIDE ( [Sum Sales], [Sum Target] )
)

 

 

BTW, you can simplify your measures by using the IN expression:

https://www.sqlbi.com/articles/understanding-the-in-operator-in-dax/ 

So, here is the equivalent to the measure your are using:

Sum using || =
CALCULATE (
    SUM ( fTable[Sales] ),
    fTable[Product] = "A"
        || fTable[Product] = "B"
        || fTable[Product] = "c"
)

and here is the simpler measure using the IN expression:

SUM using IN = 
CALCULATE([Sum Sales], fTable[Product] IN {"A", "B", "C"})

and here is the comparison in a table visual:

comparison.png

 

I've attached a sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

9 REPLIES 9
PaulDBrown
Community Champion
Community Champion

See if this works for you (I've created separate measures for the numerator and denominator because it's easier to read, but you can do it all in one measure if you wish)

result.png

 

 

Divide Sales by Target = 
SWITCH(
    TRUE(),
    AND(ISBLANK([Sum Sales]), [Sum Target] >0), 0,
    [Sum Target] >0,
    DIVIDE([Sum Sales], [Sum Target], 0),
    DIVIDE([Sum Sales], [Sum Target]))

 

If you want blank when the target is blank even if there is a value for sales, you can  use this measure:

 

Divide Sales by Target =
SWITCH (
    TRUE (),
    [Sum Target] > 0, DIVIDE ( [Sum Sales], [Sum Target], 0 ),
    DIVIDE ( [Sum Sales], [Sum Target] )
)

 

 

BTW, you can simplify your measures by using the IN expression:

https://www.sqlbi.com/articles/understanding-the-in-operator-in-dax/ 

So, here is the equivalent to the measure your are using:

Sum using || =
CALCULATE (
    SUM ( fTable[Sales] ),
    fTable[Product] = "A"
        || fTable[Product] = "B"
        || fTable[Product] = "c"
)

and here is the simpler measure using the IN expression:

SUM using IN = 
CALCULATE([Sum Sales], fTable[Product] IN {"A", "B", "C"})

and here is the comparison in a table visual:

comparison.png

 

I've attached a sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

Assuming the [RID ENI] measure is the division of [measure 1] by [measure 2], try:

 

RID ENI =
IF (
    [measure 2] > 0,
    DIVIDE ( [measure 1], [measure 2], 0 ),
    DIVIDE ( [measure 1], [measure 2] )
)

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






pi_eye
Resolver IV
Resolver IV

Hi HifNi93

 

PowerBI will present the results of the numbers differently from a division, depending on if you use the "/" operator, or the divide() function.

 

See below experiment using some randomly generated data:

 

pi_eye_0-1665065521833.png

(1) Straight column (as opposed to measure):  N/D = data[Numerator]/data[Denominator]

(2) Measure created using the "/" operator: sumN/sumD = sum(data[Numerator])/sum(data[Denominator])

(3) Measure created using the DIVIDE() function: Divide SumN SumD = divide(sum(data[Numerator]), sum(data[Denominator]))  

 

The "/" operator returns the NaN or infinity, whereas the Divide() function cleans these results and returns blank It doesn't not matter whether it is a measure or Calculated column.

 

This means you can use the result of the "/" to tailor what output is returned.

This switch statement interprets the text returned by sumN/sumD and displays a custom string:

 

Switch sumN/SumD = switch(convert([sumN/sumD],string) ,"-nan(ind)","~ Not a number~","inf","~Infinity~","","Blank",[sumN/sumD]   )    
 

Note the values for NaN and Infinity are different when converted to a string!

 

Hope this gives you a few options.

 

Pi

Anonymous
Not applicable

thanks for your answer but actually nothing woks as i am using a calculate sum when i converted the results to strings it's still blanks 

Hifni93_0-1665070597295.png

 

Can you tell how bo_value is calculated? I think the NaNs/ blanks are originating from there.

Anonymous
Not applicable

Bo_value is an orginal cloulmn, its numbers between 1-10

Hifni93_0-1665072206182.png

 

Looks like the blanks are coming from the original source. PowerBI would need more information in order to determine what type of non-real number it is.

Does the source contain the denominator? If the denonominator is present, then that could be compared with a switch statement instead.

Anonymous
Not applicable

The Denominator is also the Bo_value but with a different filter , 

Hi - in that case you just need to point an IF() statment at the denominator. Something similar to:

Testmeasure = if( ISBLANK( sum(data[Denominator])),"no value for denominator",if(sum(data[Denominator])==0,"zero","has value")) but replacing the returned values with what you would like in the column

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.