Forum Discussion
M if text contains
- 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
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
- cbusila7 years agoFrequent Visitor
What if you have for example a table with 3 columns and the content of the columns can be grouped under certain rules each rules with 3 criterias. I want to create a custom column and put on rows the coresponding rule coding.
In order to put the rule I have to check if column 1 from the table contains the criteria 1 of Rule 1, if column 2 from the table contains the criteria 2 of Rule 1 and if column 3 from the table contains the criteria 3 of Rule 1; if all are met then I put the code for rule 1
Please see the print screen attached
Do you know if there is a way to create a M code for this kind of situation?
Thx,
Ciprian
- gk2go7 years ago
Helper III
v-yulgu-msft, how to replace if it contains either of "Coca" or "Coke"?