Forum Discussion
Conditional format varchar
Hi all,
I am trying to apply condtional formatting to my table, which consists of varchar data. I cannot modify the data, since I am using DirectQuery. In order to get it working, I have tried to work with a lookup table, which creates dummies; however, this didn't give me the result I was looking for. The column gets one and the same color, regardless of the settings I have applied (color, rule, sum etc.).
Below I firstly show the table and values I am using in the original one and after that the lookup table. Is my approach even possbile? If so, could someone please help me how to configure this? Help is much appreciated, thanks in advance!
| Source | Run_status |
| Source a | 1 |
| Source b | 2 |
| Source c | 8 |
| Source d | 11 |
| Source e | B |
| Source f | E |
| Source g | F |
| Run_Status | Value |
| 1 | 1 |
| 2 | 1 |
| 11 | 2 |
| E | 2 |
| F | 2 |
| B | 3 |
| 8 | 3 |
The result I am looking for is as follows in terms of colors:
1 = green
2 = red
3 = blue
Hello @Juuls ,
This is related to the locale, replace all ";" (semicolon) by "," (comma) everything should work fine.
Check the corrected measurement below:
CondittionalFormatting = VAR Temp_table = ADDCOLUMNS ( SUMMARIZE ( Run_Status, Run_Status[Source], Run_Status[Run_Status] ), "@Status_Values", LOOKUPVALUE ( Lookup[Value], Lookup[Run_Status], Run_Status[Run_Status] ) ) RETURN SWITCH ( MAXX ( Temp_table, [@Status_Values] ), 1 , "Green" , 2 , "Red" , 3 , "Blue" )
4 Replies
- MFelixSuper User
Hi Juuls ,
Try the following code:
CondittionalFormatting = VAR Temp_table = ADDCOLUMNS ( SUMMARIZE ( Run_Status; Run_Status[Source]; Run_Status[Run_Status] ); "@Status_Values"; LOOKUPVALUE ( Lookup[Value]; Lookup[Run_Status]; Run_Status[Run_Status] ) ) RETURN SWITCH ( MAXX ( Temp_table; [@Status_Values] ); 1; "Green"; 2; "Red"; 3; "Blue" )- JuulsFrequent Visitor
Hi @MFelix ,
Firstly, thank you very much for your reply, much appreciated!
Secondly maybe a slightly stupid question; I have tried your solution, but I keep getting a syntax error near ';'.
I have tried generating a measure, column and table with the code without success unfortunately.
I probably am doing something wrong, but since I'm rather new to this I hope you can tell me how.
Thanks once more!
Regards,
Juul
- MFelixSuper User
Hello @Juuls ,
This is related to the locale, replace all ";" (semicolon) by "," (comma) everything should work fine.
Check the corrected measurement below:
CondittionalFormatting = VAR Temp_table = ADDCOLUMNS ( SUMMARIZE ( Run_Status, Run_Status[Source], Run_Status[Run_Status] ), "@Status_Values", LOOKUPVALUE ( Lookup[Value], Lookup[Run_Status], Run_Status[Run_Status] ) ) RETURN SWITCH ( MAXX ( Temp_table, [@Status_Values] ), 1 , "Green" , 2 , "Red" , 3 , "Blue" )