Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I wrote the following DAX to calculate a percentage, but I want it to show "0%" if blank and I can't get it to work 😞
Solved! Go to Solution.
If you want the result to be displayed as "0%" when it is blank, you can modify the DAX formula as follows:
LOBs Penetrated percent equal to 1 =
VAR __FILTERED_VALUE =
CALCULATE(
COUNT('R&B LOB Revenue'[LOBs Penetrated]),
KEEPFILTERS('R&B LOB Revenue'[LOBs Penetrated] = 1)
)
VAR __MEASURE_VALUE = COUNT('R&B LOB Revenue'[LOBs Penetrated])
VAR __RESULT =
DIVIDE(
__FILTERED_VALUE,
__MEASURE_VALUE
)
RETURN
IF(
ISBLANK(__RESULT),
"0%",
FORMAT(__RESULT, "0%")
)
In this modified formula, the IF function checks if the result (__RESULT) is blank using the ISBLANK function. If it is blank, the formula returns the text value "0%". Otherwise, it formats the result as a percentage using the FORMAT function.
Now, when the result is blank, it will be displayed as "0%", and when it is not blank, it will be displayed as a percentage value.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
If you want the result to be displayed as "0%" when it is blank, you can modify the DAX formula as follows:
LOBs Penetrated percent equal to 1 =
VAR __FILTERED_VALUE =
CALCULATE(
COUNT('R&B LOB Revenue'[LOBs Penetrated]),
KEEPFILTERS('R&B LOB Revenue'[LOBs Penetrated] = 1)
)
VAR __MEASURE_VALUE = COUNT('R&B LOB Revenue'[LOBs Penetrated])
VAR __RESULT =
DIVIDE(
__FILTERED_VALUE,
__MEASURE_VALUE
)
RETURN
IF(
ISBLANK(__RESULT),
"0%",
FORMAT(__RESULT, "0%")
)
In this modified formula, the IF function checks if the result (__RESULT) is blank using the ISBLANK function. If it is blank, the formula returns the text value "0%". Otherwise, it formats the result as a percentage using the FORMAT function.
Now, when the result is blank, it will be displayed as "0%", and when it is not blank, it will be displayed as a percentage value.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Worked like a charm! Thank you very much 🙂
@dave_f ,
Have you tried this one? By keeping output in the result variable and use conditional statement in return,
LOBs Penetrated percent equal to 1 = VAR __FILTERED_VALUE = CALCULATE(
COUNT(
'R&B LOB Revenue'[LOBs Penetrated]
),
KEEPFILTERS(
'R&B LOB Revenue'[LOBs Penetrated]
= 1
)
)
VAR __MEASURE_VALUE = COUNT(
'R&B LOB Revenue'[LOBs Penetrated]
)
VAR _result = DIVIDE(
__FILTERED_VALUE,
__MEASURE_VALUE
)
RETURN IF(ISBLANK(_resutl),"0%",_result)
Thanks,
Arul
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
75 | |
54 | |
37 | |
31 |
User | Count |
---|---|
99 | |
56 | |
50 | |
42 | |
40 |