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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Divide, Calculate Returning 100% even if 0

Below is the measure I am using to calcuate Compliance %- the issue I am having-
when both come back 0- it returns 100%- it is probably a simple solution, but I have spent far too long scratching my head here.   When I try to alternate of ),0), for the Divide function it does nothing.
 
Thank you
 
Compliance = calculate(
DIVIDE(
CALCULATE (COUNTROWS(Append1),Append1[Compliant]="Compliant"),
CALCULATE (COUNTROWS(Append1),Append1[Status]="Closed")),
Filter(Append1,Append1[Site]="X")
)
1 ACCEPTED SOLUTION

@Anonymous 
Please try this 

Compliance =
VAR Comp =
    CALCULATE (
        COUNTROWS ( Append1 ),
        Append1[Compliant] = "Compliant",
        FILTER ( Append1, Append1[Site] = "X" )
    )
VAR Closed =
    CALCULATE (
        COUNTROWS ( Append1 ),
        Append1[Status] = "Closed",
        FILTER ( Append1, Append1[Site] = "X" )
    )
RETURN
    IF ( Comp = BLANK () || Closed = BLANK (), 0, DIVIDE ( Comp, Closed ) )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Thank you @Fowmy ,

 

When I try that though, it still returns 100%, even if both numerator and denominator are 0 or blank.

Please share a screenshot of the DAX measure and the visual

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hanger_1-1653334700327.png

 

@Anonymous 
What do you expect if both return ZERO?
Can you share a sample PBIX file?

Instead of Filter(Append1,Append1[Site]="X"), try Append1[Site]="X"

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

I tried to use Append1[Site]="X" as suggested and it returned an error to the visual.

 

Ideally if both return 0- I need it to say 0% instead of 100%-  trying to figure out how to share a file without giving out data that is unshareable.  Not sure I can.  

 

Basically if 90 are Compliant and 100 are Closed, then the return is 90%.  Currently if Compliant is BLANK and Closed are BLANK it is still returning 100% rather than a null or 0.  

@Anonymous 
Please try this 

Compliance =
VAR Comp =
    CALCULATE (
        COUNTROWS ( Append1 ),
        Append1[Compliant] = "Compliant",
        FILTER ( Append1, Append1[Site] = "X" )
    )
VAR Closed =
    CALCULATE (
        COUNTROWS ( Append1 ),
        Append1[Status] = "Closed",
        FILTER ( Append1, Append1[Site] = "X" )
    )
RETURN
    IF ( Comp = BLANK () || Closed = BLANK (), 0, DIVIDE ( Comp, Closed ) )
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

I just saw this, and was going to suggest the variables.  Great job helping solve this.  Variables are always a great way to see what the values are against what you think they are.

Anonymous
Not applicable

Thank you so much @Fowmy that solved it!!!

Fowmy
Super User
Super User

@Anonymous 

You can use the 3rd argument of DIVIDE as zero

Compliance =
CALCULATE (
    DIVIDE (
        CALCULATE ( COUNTROWS ( Append1 ), Append1[Compliant] = "Compliant" ),
        CALCULATE ( COUNTROWS ( Append1 ), Append1[Status] = "Closed" ),
        0
    ),
    Append1[Site] = "X"
)
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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