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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
dblank1974
Regular Visitor

Conditional formating on strings

I need help with conditional formating within one cell.  The below example highlighted is whoat I would like to format.  I need it to be able to compare between Crtical, High, Medium, and Low then take the highest value (being Critical) and removing the rest.  Any suggestions?

 

new_snip_1.png

1 ACCEPTED SOLUTION
Peter_Beck
Resolver II
Resolver II

HI -

 

Here is a possible solution in "M". This assumes your table is called "Data", and will generate a new table called "NewTable"

 

let
NewTable = Table.AddColumn(Data, "NewColumn",
each
if Text.Contains( [Severity], "Critical") then "Critical"
else
if Text.Contains( [Severity], "High") then "High"
else
if Text.Contains( [Severity], "Medium") then "Medium"
else
"None")
in
NewTable

 

It uses the Table.AddColumn function. This requires a table (called in the case "Data") a column name (called "NewColumn", you can call it what you want) and then a function. The "each" keyword acts as an iterator, passing the column called "Severity" through nested if-clauses to return only a single value.

 

Hope this helps!

 

Peter

View solution in original post

3 REPLIES 3
Peter_Beck
Resolver II
Resolver II

HI -

 

Here is a possible solution in "M". This assumes your table is called "Data", and will generate a new table called "NewTable"

 

let
NewTable = Table.AddColumn(Data, "NewColumn",
each
if Text.Contains( [Severity], "Critical") then "Critical"
else
if Text.Contains( [Severity], "High") then "High"
else
if Text.Contains( [Severity], "Medium") then "Medium"
else
"None")
in
NewTable

 

It uses the Table.AddColumn function. This requires a table (called in the case "Data") a column name (called "NewColumn", you can call it what you want) and then a function. The "each" keyword acts as an iterator, passing the column called "Severity" through nested if-clauses to return only a single value.

 

Hope this helps!

 

Peter

It worked perfectly.  Thank you

Here is a pic of the result. I realized that I did no include an option for "low", you will need to add that yourself as an option at the end of the if clause. 

 

ScreenHunter_98 Feb. 26 10.44.jpg

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.