Forum Discussion
benjamin_sasin
Resolver I
6 years agoReplacing Blanks in Power Query inside a Table.ReplaceValue() function
I am trying to figure out how to replace blanks in Power Query, but all Google an Forum search lead me to using DAX, which is not what I am looking for, as I want to use Power M query. Also, searchin...
dax
Community Support
6 years agoHi benjamin_sasin ,
You said that some rows didn't replace blank, right? I think this might be cause by space, some rows are " " instead of "", so when you use "", it doesn't work. You could try below M code to see the difference and see whetehr it work or not
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTJUitWJVkoGssAMBSDDGMwCMvJKc3Lg0qZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t, Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"Column1", Int64.Type}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "name", "name - Copy"),
#"Replaced Value1" = Table.ReplaceValue(#"Duplicated Column","","replace",Replacer.ReplaceValue,{"name - Copy"}),
#"Replaced Value" = Table.ReplaceValue(#"Replaced Value1",each [name],each if Text.Trim([name])="" then "replace blank" else [name],Replacer.ReplaceValue,{"name"})
in
#"Replaced Value"
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
elishaveriwa
3 years agoRegular Visitor
You really served my day 🤗 🤝.