Forum Discussion
RE
Helper I
9 years agoM if text contains
I'm fairly new to M and I'm not sure if this functionality is even avaliable but what I'm trying to do is replace text that contians a specific word. For example, In my data set I have the same compa...
- 9 years ago
Hi RE,
Here are two options for your reference
1. add a conditional column
Corresponding M query:
= Table.AddColumn(#"PreviousStep", "Custom", each if Text.Contains([Column1], "Coca") then "Coca Cola" else [Column1] )
2. Replace values on original column directly.
#"Replaced Value" = Table.ReplaceValue( #"PreviousStep" ,each [Column1],each if Text.Contains([Column1], "Coca") then "Coca Cola" else [Column1],Replacer.ReplaceValue,{"Column1"})Best regards,
Yuliana Gu
monmon_bi
9 years agoFrequent Visitor
You can use Text.Contains.
For example,
[Custom] = if Text.Contains("Coca", [Company]) then "Coca Cola" else [Company]
Anonymous
4 years agoNot applicable
If anyone ever finds this topic with a similar question, this solution doesn't work.
Not sure if the formula requirements changed over the years, but it should be like this
if Text.Contains([Company], "Coca") then "Coca Cola" else [Company]