Forum Discussion
Einomi
4 years agoHelper V
Text.Contain or List.Contain
Hello I have the following column in my table Description Hello AADF 456 Hello GTYH 456 Hello AADF 987 Hello GTYH 987 I would like please a M code to be able to identify...
- 4 years ago
If you are looking for multiple words in a column, and then outputting a code, the "best" way to do that probably depends on the nature of your actual problem.
One "simple" method is with a Custom Column using List.ContainsAll:
if List.ContainsAll(Text.Split([Description]," "),{"Hello","456"}) then "H1" else if List.ContainsAll(Text.Split([Description]," "), {"Hello","987"}) then "H2" else nullHowever, if you have many possible combinations, using a lookup table approach might be more flexible.
AlexisOlson
4 years agoSuper User
You could use multiple Text.Contains functions.
if Text.Contains([Description], "Hello") then
if Text.Contains([Description], "456") then "H1"
else if Text.Contains([Description], "987") then "H2"
else "Other"