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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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