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
MichaelO
Regular Visitor

Conditional Formatting on Field Value Switch not working

Hi,

 

I am trying to use a measure to change the font colour and title of a visual card.

 

The switch function has been set up to determin colour based on 2 meassure.

I want the colour to be green if current week is larger than previous week.

I want the colour to be red if current week is smaller than previous week.

Font Colour = SWITCH(
    TRUE(),
        [Current Week] > [Previous Week], "green",
        [Current Week] < [Previous Week], "red", "black" )

This meassure works correctly as a card shows the return is red. However, for some reason the conditional formatting is using the green format.
The card title confirms this as the title conditional formatting says green. Even though the field is using thE same meassure - "Font Colour."
 
MichaelO_0-1665489863367.png

 

I have tried rearranging the order of my formula to show red first and this hasnt made a difference.

I have used if statements as well and no difference. The font colour result shows red in the 3rd card, however the conditional format says green.

 

Any help on why the conditional formatting is not recognising the correct value will be greatly appreciated.


Best,

Michael

2 REPLIES 2
MichaelO
Regular Visitor

Thank you for your reply, v-zhangt. I appreciate it!

 

That is so strange. But I believed it would be the case. I do not understand why it goes wrong when I place the measure in that specific visual card.

 

Please find the measures for Current week and Previous week:

 

MichaelO_0-1665568779624.png

MichaelO_1-1665568933553.png

 

I shall keep trying and see what happens when I use other measures to try and narrow the problem down.

 

Best,

Michael

 

v-zhangti
Community Support
Community Support

Hi, @MichaelO 

 

I tried to reproduce your problem, but unsuccessfully. You can refer to my measure calculation.

Sample data:

vzhangti_2-1665539392511.png

Current Week = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),[Week]=WEEKNUM(TODAY(),2)))
Previous Week = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),[Week]=WEEKNUM(TODAY(),2)-1))

vzhangti_1-1665539073875.png

You can expand the value of [Current Week] in the table to see if there is a problem with the calculation.

 

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.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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