Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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

 

ProcessNameIdentAreaTypReasonVersion
AbData Test232shopdocinitial Version1.0
ascancelled:Test2321shopdoccancelled:update Version1.2
dscancelled:Test223shopdoccancelled: document3.0
baData Test232shopdocinitial Verrsion1.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

  • edhans's avatar
    edhans
    Community 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.