Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I have a column in my table where every cell consists of one list of words. I want to replace certain word with another one from each of these lists but I am not sure how to do that. I have tried similar M language scripts as I do in the case where a column consists of text, but now I get only error messages.
Example:
| Column 1 |
| {"Cat", "Dog", "Mouse"} |
| {"Cat, Dog"} |
| {"Dog"} |
| {"Dog", "Tiny Mouse"} |
So the "elements" in this column are lists. Say I want to change all "Mouse" words to "Rat". The desired result would be:
| Column 1 |
| {"Cat", "Dog", "Rat"} |
| {"Cat, "Dog"} |
| {"Dog"} |
| {"Dog", "Tiny Rat"} |
Solved! Go to Solution.
Use this
= Table.ReplaceValue(Custom1, each [Column 1], each List.Transform([Column 1],(x)=>Text.Replace(x,"Mouse","Rat")), Replacer.ReplaceValue,{"Column 1"})
Can you please post some sample data from table and also list of replacement words?
Hi, I added an example to my original message.
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test
Important for you is the last Table.ReplaceValue.
I have used first Table.ReplaceValue for converting your example values into a list.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wqo5Rck4siVHSUYhRcslPhzB880uLU2OUapVidbCogAtj4aHqjgUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t]),
Custom1 = Table.ReplaceValue(Source, each [Column 1], each Expression.Evaluate([Column 1]),Replacer.ReplaceValue,{"Column 1"}),
Custom2 = Table.ReplaceValue(Custom1, each [Column 1], each List.ReplaceMatchingItems([Column 1],{{"Mouse","Rat"}}), Replacer.ReplaceValue,{"Column 1"})
in
Custom2
Thank you! I used the Table.ReplaceValue line and got it to work. Further, would it be possible to replace some part of a word as well?
For example, if one of those lists included a word "Tiny Mouse" and I wanted it to be replaced with "Tiny Rat" as well?
Use this
= Table.ReplaceValue(Custom1, each [Column 1], each List.Transform([Column 1],(x)=>Text.Replace(x,"Mouse","Rat")), Replacer.ReplaceValue,{"Column 1"})
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.