Forum Discussion
Use conditional formatting in tables
Hallo Community,
i have the following question:
if in column Reason initial Version is written, the font color in column Reason, Version shall be green.
If in column Reason cancelled:...text is variable.... the font color in column Name, Reason, Version should be red.
I have written the following measure
Color =
Var Colortype = SELECTEDVALUE(Datenbank[Reason])
RETURN
SWITCH(TRUE),
Colortype = "initial Version",1,
Colortype = "*cancelled:* ???",1,) <--- how should i write this ??
Thx for your help
| Process | Name | Ident | Area | Typ | Reason | Version |
| Ab | Data Test | 232 | shop | doc | initial Version | 1.0 |
| as | cancelled:Test2 | 321 | shop | doc | cancelled:update Version | 1.2 |
| ds | cancelled:Test | 223 | shop | doc | cancelled: document | 3.0 |
| ba | Data Test | 232 | shop | doc | initial Verrsion | 1.0 |
Use the FIND() function Anonymous
SWITCH( TRUE(), Colortype = "initial Version", "Green" FIND("cancelled", Colortype, 1, 0) > 0, "Red", "Black" )If ColorType contains cancelled anywhere, it will return the place, and if > 0, will return the red color.
NOTE: FIND() is case sensitive, and doesn't support Wildcards. You night want to use SEARCH() instead, which does support wildcards, and is case-insensitive. The syntax is identical. SEARCH(TextToSearchFor, TextToSearchIn, StartPosition, ValueIfNotFound)
StartPosition for both must be >=1, and ValueIfNotFound is required in your case, otherwise it will return an error. If you return 0, then it will return false if the text isn't found.
1 Reply
- edhansCommunity Champion
Use the FIND() function Anonymous
SWITCH( TRUE(), Colortype = "initial Version", "Green" FIND("cancelled", Colortype, 1, 0) > 0, "Red", "Black" )If ColorType contains cancelled anywhere, it will return the place, and if > 0, will return the red color.
NOTE: FIND() is case sensitive, and doesn't support Wildcards. You night want to use SEARCH() instead, which does support wildcards, and is case-insensitive. The syntax is identical. SEARCH(TextToSearchFor, TextToSearchIn, StartPosition, ValueIfNotFound)
StartPosition for both must be >=1, and ValueIfNotFound is required in your case, otherwise it will return an error. If you return 0, then it will return false if the text isn't found.