Forum Discussion

MichaelO's avatar
MichaelO
Regular Visitor
3 years ago

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

 

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

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, MichaelO 

     

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

    Sample data:

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

    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.

  • MichaelO's avatar
    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:

     

     

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

     

    Best,

    Michael