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
Grizzlydad
Helper I
Helper I

Create new column returning a value based on multiple criteria in another column

Hiya all

 

I have a table which has one column with a lot of text in it.  I wish to search that text and identify whether the word "ALERT or RESPONSE" was used and whicg region was contained in the text.  For example, see below, how do I check if NORTH EAST and ALERT were used to return a value of Yes.  Please bear in mind it may be any location (there are several in the organisation) and I would like to search for the words ALERT or RESPONSE being used in that column too.

NORTH EAST HAVE DECLARED REGIONAL ALERT WITH IMMEDIATE EFFECT IN RELATION TO

 

Best regards

 

Grizzly

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Grizzlydad 

Is this problem sloved? 
If it is sloved, could you kindly accept it as a solution to close this case and help the other members find it more quickly?
If not, please feel free to let me know.
 
Best Regards
Maggie
edhans
Super User
Super User

Can you provide a table of example data and a screenshot perhaps of the expected result, or sample columns with the expected result?

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



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

MessageRegionResponseAlert
THE NORTH WEST REGION HAS ESCALATED TO REGIONAL ALERT DUE TO  PROTESTS TOMORROW MORNING WHICH WILL IMPACT ON THE NORTH WEST NETWORK. North WestNoYes
    
    
    
    

So I want to extract from the message column, which region and whether alert or response was used.  The message column often contains text written inconsitently

Please try out the M code below for one way to accomplish this.  It used Text.Split and List.Intersect to break your message into a list and find all the regions and response types (Alert or Response) in the text.

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY3BCsMwDEN/ReQ89g8hNU1YahfHI4zSY2G3wdr/p97YaRcJPZC0LMEygUUto1MzKI1FGDk2UEuxRqMBJj8eK2IlNQx3+lDMKua15mESVelw48Ijei7JN0utKNMck8Fn/86YrIvergiXwK/38UTf9uMbXB7bHtb1BA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Message = _t, Region = _t, Response = _t, Alert = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Message", type text}, {"Region", type text}, {"Response", type text}, {"Alert", type text}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","NORTH WEST","NORTHWEST",Replacer.ReplaceText,{"Message"}),
RegionList = {"NORTH","SOUTH", "EAST", "WEST","NORTHEAST","NORTHWEST","SOUTHEAST","SOUTHWEST"},
#"Added Custom" = Table.AddColumn(#"Replaced Value", "FoundRegions", each Text.Combine(List.Intersect({Text.Split([Message]," "),RegionList}),"; "), type text),
Custom1 = Table.AddColumn(#"Added Custom", "ResponseType", each Text.Combine(List.Intersect({Text.Split([Message]," "),{"RESPONSE","ALERT"}}),"; "), type text)
in
Custom1

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.