Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I need help to use in M (query editor) the replacevalue function for multiple strings. This is what I have so far:
Table.ReplaceValue(Source,each [COLUMN1], each if(
{"String1","StringReplaced1"}
{"String2","StringReplaced2"}
{"String3","StringReplaced3"}
{"String4","StringReplaced4"}
{"String5","StringReplaced5"}
{"String6","StringReplaced6"}
{"String7","StringReplaced7"}
{"String8","StringReplaced8"}
{"String9","StringReplaced9"}
{"String10","StringReplaced10"}
{"String11","StringReplaced11"}
{"String12","StringReplaced12"}
{"String13","StringReplaced13"}
{"String14","StringReplaced14"}
else "N/A")
The idea is to replace from a a specific column different strings/text.
Example replace "String1" with "StringReplaced1" and so on ..
Hope you can help me.
Thanks.
Solved! Go to Solution.
Hi @cristianml ,
Please have a try.
Table.ReplaceValue(#"Changed Type", each [COLUMN],
each if Text.Contains([COLUMN], "String1") then Text.Replace([Custom], "String1", "StringReplaced1")
else if Text.Contains([COLUMN], "String2") then Text.Replace([Custom], "String2", "StringReplaced2")
else if Text.Contains([COLUMN], "String3") then Text.Replace([Custom], "String3", "StringReplaced3")
else if Text.Contains([COLUMN], "String4") then Text.Replace([Custom], "String4", "StringReplaced4")
else if Text.Contains([COLUMN], "String5") then Text.Replace([Custom], "String5", "StringReplaced5")
else if Text.Contains([COLUMN], "String6") then Text.Replace([Custom], "String6", "StringReplaced6")
else if Text.Contains([COLUMN], "String7") then Text.Replace([Custom], "String7", "StringReplaced7")
else if Text.Contains([COLUMN], "String8") then Text.Replace([Custom], "String8", "StringReplaced8")
else if Text.Contains([COLUMN], "String9") then Text.Replace([Custom], "String9", "StringReplaced9")
else if Text.Contains([COLUMN], "String10") then Text.Replace([Custom], "String10", "StringReplaced10")
else if Text.Contains([COLUMN1], "String11") then Text.Replace([Custom], "String11", "StringReplaced11")
else if Text.Contains([COLUMN], "String12") then Text.Replace([Custom], "String12", "StringReplaced12")
else if Text.Contains([COLUMN], "String13") then Text.Replace([Custom], "String13", "StringReplaced13")
else if Text.Contains([COLUMN], "String14") then Text.Replace([Custom], "String14", "StringReplaced14")
else "NA", Replacer.ReplaceText,{"COLUMN"})
If I have misunderstood your meaning, please provide more details with your desired output and your pbix file without privacy information.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @cristianml ,
Please have a try.
Table.ReplaceValue(#"Changed Type", each [COLUMN],
each if Text.Contains([COLUMN], "String1") then Text.Replace([Custom], "String1", "StringReplaced1")
else if Text.Contains([COLUMN], "String2") then Text.Replace([Custom], "String2", "StringReplaced2")
else if Text.Contains([COLUMN], "String3") then Text.Replace([Custom], "String3", "StringReplaced3")
else if Text.Contains([COLUMN], "String4") then Text.Replace([Custom], "String4", "StringReplaced4")
else if Text.Contains([COLUMN], "String5") then Text.Replace([Custom], "String5", "StringReplaced5")
else if Text.Contains([COLUMN], "String6") then Text.Replace([Custom], "String6", "StringReplaced6")
else if Text.Contains([COLUMN], "String7") then Text.Replace([Custom], "String7", "StringReplaced7")
else if Text.Contains([COLUMN], "String8") then Text.Replace([Custom], "String8", "StringReplaced8")
else if Text.Contains([COLUMN], "String9") then Text.Replace([Custom], "String9", "StringReplaced9")
else if Text.Contains([COLUMN], "String10") then Text.Replace([Custom], "String10", "StringReplaced10")
else if Text.Contains([COLUMN1], "String11") then Text.Replace([Custom], "String11", "StringReplaced11")
else if Text.Contains([COLUMN], "String12") then Text.Replace([Custom], "String12", "StringReplaced12")
else if Text.Contains([COLUMN], "String13") then Text.Replace([Custom], "String13", "StringReplaced13")
else if Text.Contains([COLUMN], "String14") then Text.Replace([Custom], "String14", "StringReplaced14")
else "NA", Replacer.ReplaceText,{"COLUMN"})
If I have misunderstood your meaning, please provide more details with your desired output and your pbix file without privacy information.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
73 | |
70 | |
38 | |
24 | |
23 |
User | Count |
---|---|
96 | |
93 | |
50 | |
41 | |
40 |