Forum Discussion
coolshib
5 years agoHelper III
Need help on Search and replace value in power query
Hello Everyone, i am looking for custom function which would check If contains "Dr" or "Cr" and replace the same will nothing and also multiplies with 1 if the word is "Dr" and multiplies with -1 ...
- Anonymous5 years ago
Hi coolshib
If you only have Cr or Dr in the column, you can use if statement
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjKzMDcx0DMwUHAuUorViVYyNDM1MjFCFjECAgsQ3wXIjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Column1],"Cr") then Number.From(Text.Select([Column1],{"0".."9"}))*-1 else Number.From( Text.Select([Column1],{"0".."9"})), type number) in #"Added Custom"
Anonymous
5 years agoNot applicable
Hi coolshib
If you only have Cr or Dr in the column, you can use if statement
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjKzMDcx0DMwUHAuUorViVYyNDM1MjFCFjECAgsQ3wXIjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each
if Text.Contains([Column1],"Cr")
then Number.From(Text.Select([Column1],{"0".."9"}))*-1
else Number.From( Text.Select([Column1],{"0".."9"})), type number)
in
#"Added Custom"
- coolshib5 years agoHelper III
Thank you so much Anonymous !! This is Exactly what i wanted..