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
Anonymous
4 years agoNot applicable
Hi,
I've added this code but
Table.AddColumn(#"Filtered Rows4", "Custom", each if Text.Contains([Cost Recovery Original column], "Slaughter") then "Slaughter" else "Not Slaughter")I'm getting the incorrect result. I'm expecting row 35 which contains the word "Slaughter" to return "Slaughter" not "Error"
Any assistance would be appreciated
Anonymous
4 years agoNot applicable
I can do this in Dax
Custom test = CALCULATE(CONTAINSSTRING(MAX('All Data'[Cost Recovery Original column]),"Slaughter"))but Mcode isn't working