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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
alks_skla_f
Frequent Visitor

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
v-zhangtin-msft
Community Support
Community Support

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
v-zhangtin-msft
Community Support
Community Support

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors