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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
avivbnbn24
Frequent Visitor

condition formatting not working as expected

Hi, I have a matrix table that includes branch number in rows, date in columns, and issued card measure in values. I want to create a condition formatting in the value field.

in the value field I put a new measure that includes some conditions :

colored format =
VAR TargetValue = [issued_card]
VAR HoursValue = [working_hours]

VAR IsTargetEmpty = ISBLANK(TargetValue) || TargetValue = 0
VAR IsHoursEmpty = ISBLANK(HoursValue) || HoursValue = 0

RETURN
SWITCH(
TRUE(),
IsTargetEmpty && IsHoursEmpty, "#FF0000", // Red
IsTargetEmpty, "#FFA500", // Orange
BLANK() // No color
)


There are relationships between date and working_hours and between branches and working hours. and of course between date, branches, and issued card. 

For some reason, the formatting condition works only when I add the working hours to the visual. I don't want that measure to appear in the visual, but when I remove it, the condition formatting doesn't work as expected. 


help me out here guys

1 ACCEPTED SOLUTION
v-bmanikante
Community Support
Community Support

Hi @avivbnbn24 ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

@johnt75 , @pankajnamekar25 , @bhanu_gautam Thank you all for your quick response.

 

Attached is a sample Power BI report with mock data that demonstrates the conditional formatting logic based on your scenario. Please check it out and let me know if you need help adjusting it to your actual dataset.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


Regards,
B Manikanteswara Reddy

 

 

View solution in original post

7 REPLIES 7
v-bmanikante
Community Support
Community Support

Hi @avivbnbn24 ,

 

Thank you for reaching out to Microsoft Fabric Community Forum.

@johnt75 , @pankajnamekar25 , @bhanu_gautam Thank you all for your quick response.

 

Attached is a sample Power BI report with mock data that demonstrates the conditional formatting logic based on your scenario. Please check it out and let me know if you need help adjusting it to your actual dataset.

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!


Regards,
B Manikanteswara Reddy

 

 

Do you know why it works only with 0 and not blank?

That helped me!

After I looked at your solution, I understood that the problem was with the measure [ISSUED_CARD].
When the value was 0, the condition formatting worked, but when it was blank, it didn't. So I changed all values to 0 instead of blank. 
It brings other problems, but things I could handle. Do 
you have any idea why it works only with 0 and not blank?

??

johnt75
Super User
Super User

The easiest way to debug this would be to store the result of the switch statement in a new variable, and then change the measure to return each variable in turn. Add the measure to the matrix so you can see the results, and you should be able to see which variable is not being computed in the way you planned.

pankajnamekar25
Super User
Super User

Hello @avivbnbn24 

 

You can try below measure

 

colored format =

VAR TargetValue = [issued_card]

VAR HoursValue = CALCULATE([working_hours])  // Force context propagation

 

VAR IsTargetEmpty = ISBLANK(TargetValue) || TargetValue = 0

VAR IsHoursEmpty = ISBLANK(HoursValue) || HoursValue = 0

 

RETURN

SWITCH(

    TRUE(),

    IsTargetEmpty && IsHoursEmpty, "#FF0000", // Red

    IsTargetEmpty, "#FFA500", // Orange

    BLANK() // No color )

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated

bhanu_gautam
Super User
Super User

@avivbnbn24 , Try using

DAX
colored format =
VAR TargetValue = [issued_card]
VAR HoursValue = CALCULATE([working_hours])

VAR IsTargetEmpty = ISBLANK(TargetValue) || TargetValue = 0
VAR IsHoursEmpty = ISBLANK(HoursValue) || HoursValue = 0

RETURN
SWITCH(
TRUE(),
IsTargetEmpty && IsHoursEmpty, "#FF0000", // Red
IsTargetEmpty, "#FFA500", // Orange
BLANK() // No color
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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.

Top Solution Authors