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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
carlol
Helper IV
Helper IV

Define Percentage format in DAX

Coverage% = If(Divide(SUM('IHFD vwCoverage'[IHFD]),SUM('IHFD vwCoverage'[HIPE]))>1,100,FORMAT(Divide(SUM('IHFD vwCoverage'[IHFD]),SUM('IHFD vwCoverage'[HIPE])),"0.0%"))
 
For Percentages greater than 100% I set to 100% , but I want to display 100% (No decimal place 0%) in this instance and when percentage is less than 100 .ie. 98.7 I want to illustrate as 0.0%
 
I tried setting the measure to General format via the modelling menu and I tried setting the default format to Percentage with 0 decimal places in the via the modelling menu, use dax as above to set to 1 decemial place 
 
Can this be done in dax, have two different formats based on derived value
 
 
 
1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @carlol,

If I understand your challenge, you want something like the corresponding value on the right for the calculated value on the left?

image.png

If so, your original measure is almost there - the issue is that the 100 you're returning for your > 100 scenario is being treated as a raw number, and then a text value for anything less than that in the form of the FORMAT calculation. The result is just stuck in as resolved.

To make all values the same type, just modify the 100 to the text value "100%", e.g.:

Coverage% =
IF (
    DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) ) >= 1,
    "100%",
    FORMAT (
        DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) ),
        "0.0%"
    )
)

(note that your orignal formula would return anything derived as 100% as "100.0%" as this isn't greater than 1, so I modified the operator to be greater than or equal to)

Here's an alternative solution that reduces calculation logic for the % result and gives you a threshold you can easily modify if you change your logic later on:

Coverage % =
VAR Threshold = 1
VAR Result =
    DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) )
RETURN
    IF (
        Result >= Threshold,
        FORMAT ( Threshold, "0%" ),
        FORMAT ( Result, "0.0%" )
    )

Hopefully this is all you need to carry on.

Good luck!

Daniel


If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

Hi @carlol,

If I understand your challenge, you want something like the corresponding value on the right for the calculated value on the left?

image.png

If so, your original measure is almost there - the issue is that the 100 you're returning for your > 100 scenario is being treated as a raw number, and then a text value for anything less than that in the form of the FORMAT calculation. The result is just stuck in as resolved.

To make all values the same type, just modify the 100 to the text value "100%", e.g.:

Coverage% =
IF (
    DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) ) >= 1,
    "100%",
    FORMAT (
        DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) ),
        "0.0%"
    )
)

(note that your orignal formula would return anything derived as 100% as "100.0%" as this isn't greater than 1, so I modified the operator to be greater than or equal to)

Here's an alternative solution that reduces calculation logic for the % result and gives you a threshold you can easily modify if you change your logic later on:

Coverage % =
VAR Threshold = 1
VAR Result =
    DIVIDE ( SUM ( 'IHFD vwCoverage'[IHFD] ), SUM ( 'IHFD vwCoverage'[HIPE] ) )
RETURN
    IF (
        Result >= Threshold,
        FORMAT ( Threshold, "0%" ),
        FORMAT ( Result, "0.0%" )
    )

Hopefully this is all you need to carry on.

Good luck!

Daniel


If my post helps, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Thanks Daniel!

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.