Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
56 | |
38 | |
35 |
User | Count |
---|---|
85 | |
66 | |
59 | |
46 | |
45 |