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
alks_skla_f
Helper II
Helper II

Conditional formatting doesn't work

Hello, 
I have a card visualisation which shows a number (I checked that this is a number because I can perform different calculations with the result. My task is to color number inside card base on conditions.
I have a mesure which helps me to set a color: 

Absolute_difference_CY_and_PY_color = 
    IF(
        [CY_current_month_total_num_patient] - [PY_current_month_total_num_patient] < 0,
        "#EE2000",  // Red for negative
        IF(
            [CY_current_month_total_num_patient] - [PY_current_month_total_num_patient] = 0,
            "#000000",  // Black for zero
            "#04FF00"   // Green for positive
        )
    )

 After I set a conditional formatting: Callout values -> Series All (I don't know what this means) -> Color -> Format syle: Field Value -> What field should we base on: Absolute_difference_CY_and_PY_color
This is doesn't work. Where is my mistake, please?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @alks_skla_f 

 

I've simply modelled some data that I hope will solve your problem.

Measure Color = SWITCH(TRUE(),
[Current]-[Previous]<0,"#EE2000",
[Current]-[Previous]=0,"#000000",
"#04FF00")

vzhangtinmsft_0-1739760434546.png

Displayed in the card.

vzhangtinmsft_1-1739760497960.pngvzhangtinmsft_2-1739760509218.png

Result:

vzhangtinmsft_3-1739760552623.png

Check to see if you've added conditional formatting in the right place.

 

Best Regards,

Community Support Team _Charlotte

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

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @alks_skla_f 

 

I've simply modelled some data that I hope will solve your problem.

Measure Color = SWITCH(TRUE(),
[Current]-[Previous]<0,"#EE2000",
[Current]-[Previous]=0,"#000000",
"#04FF00")

vzhangtinmsft_0-1739760434546.png

Displayed in the card.

vzhangtinmsft_1-1739760497960.pngvzhangtinmsft_2-1739760509218.png

Result:

vzhangtinmsft_3-1739760552623.png

Check to see if you've added conditional formatting in the right place.

 

Best Regards,

Community Support Team _Charlotte

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

 

Punithurs
Frequent Visitor

Hi @alks_skla_f , 
Here are couple of screenshots, you should be good with the measure, 
But as @Fowmy mentioned, Check whether your CY and PY values are right(Numeric Formart). 
If they return integer or numeric format, you should be good to achive this color formatting.

Punithurs_0-1739651460421.pngPunithurs_1-1739651484300.png

Thanks,

Punith

Fowmy
Super User
Super User

@alks_skla_f 

You have taken the right approach, I believe the issue is in the measures involved in CF.  
1.  Add the measure "Absolute_difference_CY_and_PY_color" to card visual and check what results you get, it should show the color codes based on the conditions, check the filters applied.
2. Also, check individual measures to know if they return the expected results.
[CY_current_month_total_num_patient]  and  [PY_current_month_total_num_patient]


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
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.