Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

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
1 ACCEPTED SOLUTION
edhans
Super User
Super User

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

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.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.