Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

How to replace multiple values in query editor without creating a new column

Hi Team,

Because my other queries rely on the old format, I need to remove the tray number (Tray: XXX | |) from the column without creating a new column. It was only because the tray number was recently added without my knowledge that some of the queries were broken.

Screenshot 2022-12-31 090358.png

1 ACCEPTED SOLUTION
HiraNegi
Resolver II
Resolver II

Hi,

 

You can achieve this by modifying or adding below line of code in the Power Query Advance editor. This will replace the values in the existing column itself.

 

#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Column1],each if Text.PositionOf([Column1],"||") = -1
then [Column1] else Text.Trim(Text.AfterDelimiter([Column1], "||"))
,Replacer.ReplaceText,{"Column1"})

 

Below is the sample data and steps.

 

sample source data:

HiraNegi_0-1672477467305.png

 

Final result after adding the replace in Advance Editor:

HiraNegi_1-1672477533788.png

 

Complete Advance Editor Code:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVjA0MlaK1YlWCilKrFSwNDJUqKlRQBaPiHQ2NzNFVmIAUhIRGaVgYW6mFBsLAA==", 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}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Column1],each if Text.PositionOf([Column1],"||") = -1
then [Column1] else Text.Trim(Text.AfterDelimiter([Column1], "||"))
,Replacer.ReplaceText,{"Column1"})

in
#"Replaced Value"

 

 

Hope this helps !!

View solution in original post

2 REPLIES 2
HiraNegi
Resolver II
Resolver II

Hi,

 

You can achieve this by modifying or adding below line of code in the Power Query Advance editor. This will replace the values in the existing column itself.

 

#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Column1],each if Text.PositionOf([Column1],"||") = -1
then [Column1] else Text.Trim(Text.AfterDelimiter([Column1], "||"))
,Replacer.ReplaceText,{"Column1"})

 

Below is the sample data and steps.

 

sample source data:

HiraNegi_0-1672477467305.png

 

Final result after adding the replace in Advance Editor:

HiraNegi_1-1672477533788.png

 

Complete Advance Editor Code:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVjA0MlaK1YlWCilKrFSwNDJUqKlRQBaPiHQ2NzNFVmIAUhIRGaVgYW6mFBsLAA==", 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}}),
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Column1],each if Text.PositionOf([Column1],"||") = -1
then [Column1] else Text.Trim(Text.AfterDelimiter([Column1], "||"))
,Replacer.ReplaceText,{"Column1"})

in
#"Replaced Value"

 

 

Hope this helps !!

FreemanZ
Super User
Super User

hi @Andrew_na_lang 

you can always delete the intermediate steps in the last step. or?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.