Forum Discussion
Switch condition adding color on rows
- 5 years ago
Hi POWER_MI ,
Since you are using measures to calculate, I still think you need to create each color format for each measure:
Color_R1 = VAR _step = SELECTEDVALUE ( Feuil1[STEP] ) RETURN SWITCH ( TRUE (), ( _step = 1 || _step = 2 || _step = 3 ), "green", _step = 5, "orange" )Color_R2 = VAR _step = SELECTEDVALUE ( Feuil1[STEP] ) RETURN SWITCH ( TRUE (), _step = 1, "green", _step = 4, "orange" )Color_R3 = VAR _step = SELECTEDVALUE ( Feuil1[STEP] ) RETURN SWITCH ( TRUE (), _step = 2, "green", _step = 4, "orange", _step = 7, "red" )Attached the file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi all,
v-yingjl Anonymous amitchandak
why when using this row
ColorFormat = SWITCH(
TRUE(),
'TABLE'[NBR_R1_Mesure] <=1000,"Green",
'TABLE'[NBR_R2_Mesure]<=1000,"Red",
"BLACK"
)
all rows color are Green ? are there any thing to add on this condition ?
thanks
Hi POWER_MI ,
Because you are using Switch() function which compares conditions by order in the formula. For example, 'TABLE'[NBR_R1_Mesure] <=1000,"Green", it compares all values in [NBR_R1_Mesure], <= 1000 will return green, it applies in the whole table visual field. If you apply this measure on these three measures, once [NBR_R1_Mesure] <=1000, it will return green, continue to judge until the end of the sentence.
You can also refer this picture in my sample:
Why not [R3] returns pink? Becasue it compares [R1] <2 firstly, then compares [R2] <=2...
Back to this case, you need to create each color format for each measure like this instead of a single measure using switch()
Measure 1 =
IF(
[Mesure_1_NBR_R1] <=3,"red"
)
Measure 2 =
IF(
[Mesure_2_NBR_R2] <=2,"green"
)
Measure 3 =
IF(
[Mesure_3_NBR_R3] <=1,"pink"
)
In essence, this is the same as using the rules to set the color format I mentioned earlier.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.