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
v-yulgu-msft
Microsoft Employee
9 years agoHi 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
gk2go
Helper III
7 years agov-yulgu-msft, how to replace if it contains either of "Coca" or "Coke"?