Forum Discussion
Anonymous
6 years agoNot applicable
create a custom query to remove phrases
Hi all,
Thank you for reading my post. I'm still learning lots with Power BI so sorry if this is a simple question to answer.
I'm trying to create a custom query to remove various phrases from my columns, Ideally I would like to embed the following into a custom function:
#"Replaced Value" = Table.ReplaceValue(#"Reordered Columns","?","",Replacer.ReplaceText,)
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value"," "," ",Replacer.ReplaceText),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","-","",Replacer.ReplaceText),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","&",",",Replacer.ReplaceText),
#"Trimmed Text" = Table.TransformColumns(#"Replaced Value3",{{Text.Trim, type text}})
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value"," "," ",Replacer.ReplaceText),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","-","",Replacer.ReplaceText),
#"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","&",",",Replacer.ReplaceText),
#"Trimmed Text" = Table.TransformColumns(#"Replaced Value3",{{Text.Trim, type text}})
Any help on this matter would be greatly appreciated.
Kind regards,
Karlos O'Neill.
let Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("i65WSjZUslJKTExJt1dTNjQzsFZLzC2wLk4sTtctTgeSCgpKOkrJRqhqUKRrYwE=",BinaryEncoding.Base64),Compression.Deflate))), fx = (txt)=>let replaced_txt= List.Accumulate({{"?",""}, {" "," "}, {"&",","}, {"-",""}},txt,(s,c)=>Text.Replace(s,c{0},c{1})) in Text.Trim(replaced_txt), result = Table.TransformColumns(Source,{},fx) in resultDo you want to replace all the column data in the table in batches, and finally perform trim operation?
Did I answer your question? Mark my post as a solution!
4 Replies
- Greg_DecklerCommunity Champion
I believe you want:
(ReplacementText as text) as text -> let #"Replaced Value" = Table.ReplaceValue(ReplacementText,"?","",Replacer.ReplaceText,) #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value"," "," ",Replacer.ReplaceText), #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","-","",Replacer.ReplaceText), #"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","&",",",Replacer.ReplaceText), #"Trimmed Text" = Table.TransformColumns(#"Replaced Value3",{{Text.Trim, type text}}) in #"Trimmed Text" - ziying35Impactful Individual
let Source = Table.FromRecords(Json.Document(Binary.Decompress(Binary.FromText("i65WSjZUslJKTExJt1dTNjQzsFZLzC2wLk4sTtctTgeSCgpKOkrJRqhqUKRrYwE=",BinaryEncoding.Base64),Compression.Deflate))), fx = (txt)=>let replaced_txt= List.Accumulate({{"?",""}, {" "," "}, {"&",","}, {"-",""}},txt,(s,c)=>Text.Replace(s,c{0},c{1})) in Text.Trim(replaced_txt), result = Table.TransformColumns(Source,{},fx) in resultDo you want to replace all the column data in the table in batches, and finally perform trim operation?
Did I answer your question? Mark my post as a solution!
- AnonymousNot applicable
Yeah, that is exactly what I'm trying to do.
- ziying35Impactful Individual
Anonymous
If any of the above code solves your problem, can you mark it as a solution?