Forum Discussion
Using OR function within Text.replace function - Power Query
- Anonymous4 years ago
Hi OsmanEmi
I suggest you to build a replacement table then try my M code. Currently, you will replace all words by the same word "Fact". This way will still work if you want to replace multiple words by different words.
My Sample:
Replacement Table:
Use M Code to add a custom column:
Text.Combine( { [Destination Type], List.Accumulate( List.Numbers(0,Table.RowCount(replacements)), [Destination Name], (state, current) => Text.Replace(state, replacements[Find]{current}, replacements[Replace]{current})) }, " | " )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello there OsmanEmi ! Try this and see if it works for your case:
= [#"DestinationType"] & " | " & Table.ReplaceValue([Your table name], each if Text.Contains([#Destination Name], {"Spend", "App", "Card"} then "Facts" else [Destination Name], Replacer.ReplaceValue, {"Destination Name"})
Alternatively, you can check this thread for a similar solution! Or this one!
Hope this answer solves your problem! If you need any additional help please tag me in your reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️ or give it a kudoe 👍
Thanks!
Best regards,
Gonçalo Geraldes