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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MFaisalMehboob
Frequent Visitor

Conditional Formatting Not Working Properly with Measures

Hi Team,

 

I am having a trouble with conditional formatting in Power BI Matrix visual. I have created the following conditional formatting on one of my measure and it is working in opposite for some rows.

Conditional Formatting.png


The value 80.65 % should be highlighted in green whereas 19.35 % should be highlighted in red, but they are being highlighted opposite. May be I am doing something wrong?

Conditional Formatting Output.png

Any help would be highly appreciated.

 

Regards,
Faisal Mehboob

1 ACCEPTED SOLUTION

Hi, @MFaisalMehboob 

Note that conditional formatting is based on an entire column of fields, not a single row of data.

In the field "capacity",80.65% is a relatively low value, so it is  highlighted in red, and 98.39% is a relatively high value, so it is highlighted in green.

In the field "booked",  1.61% is a relatively low value, so it is  highlighted in red, and 19.35% s a relatively high value, so it is highlighted in green.

 

For your needs, I suggest creating conditional formatting based on custom measure fields

Please add new measure like:

Conditional_booked =
IF (
    [Booked] <> "N/A",
    IF (
        [Booked] < [Capacity],
        "Red",
        IF ( [Booked] > [Capacity], "Green", IF ( [Booked] = [Capacity], "Yellow" ) )
    )
)
Conditional_capacity =
IF (
    [Capacity] <> "N/A",
    IF (
        [Booked] < [Capacity],
        "Green",
        IF ( [Booked] > [Capacity], "Red", IF ( [Booked] = [Capacity], "Yellow" ) )
    )
)

Then apply them to the background conditions of their respective columns.

veasonfmsft_0-1669604985821.png

 

Please checked my attached pbix for more details.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

3 REPLIES 3
MFaisalMehboob
Frequent Visitor

Hi @VahidDM,

Let me see if I can she some sample date, but here is the code for my measures.

Booked =
IF(DIVIDE(
    IF([Reserved] = BLANK(), 0 , [Reserved]),
    IF([Available] = "N/A", 0, [Available])
) = BLANK(), "N/A" , DIVIDE(
    IF([Reserved] = BLANK(), 0 , [Reserved]),
    IF([Available] = "N/A", 0, [Available])
))

 

Capacity = IF((1 - IF([Booked] = "N/A", 1 , [Booked] )) = BLANK(), "N/A", (1 - IF([Booked] = "N/A", 1 , [Booked] )))

Hi, @MFaisalMehboob 

Note that conditional formatting is based on an entire column of fields, not a single row of data.

In the field "capacity",80.65% is a relatively low value, so it is  highlighted in red, and 98.39% is a relatively high value, so it is highlighted in green.

In the field "booked",  1.61% is a relatively low value, so it is  highlighted in red, and 19.35% s a relatively high value, so it is highlighted in green.

 

For your needs, I suggest creating conditional formatting based on custom measure fields

Please add new measure like:

Conditional_booked =
IF (
    [Booked] <> "N/A",
    IF (
        [Booked] < [Capacity],
        "Red",
        IF ( [Booked] > [Capacity], "Green", IF ( [Booked] = [Capacity], "Yellow" ) )
    )
)
Conditional_capacity =
IF (
    [Capacity] <> "N/A",
    IF (
        [Booked] < [Capacity],
        "Green",
        IF ( [Booked] > [Capacity], "Red", IF ( [Booked] = [Capacity], "Yellow" ) )
    )
)

Then apply them to the background conditions of their respective columns.

veasonfmsft_0-1669604985821.png

 

Please checked my attached pbix for more details.

 

Best Regards,
Community Support Team _ Eason

VahidDM
Super User
Super User

HI @MFaisalMehboob 

 

Can you share a sample of your data with Measure codes?
Not sure, but Ithink you need to update your measure to compare numbers in each month, because I think in that row there is bigger capacity and lower Booked in June so those are correct but in July that measure compare the numbers with June as well.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.