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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hood2media
Resolver II
Resolver II

power query | replace value in 1 column based on content in another column - 2

hi,
i have a situation where contents in 1 column should be in another column & vice versa.

 

for example, a column called 'Category' has "New Year Party" and another column called "Item"has "Collection". 

the correction i need through power query is for "Collection"to be in the Category-column & "New Year Party" to be in the "Item Column".

appreciate any help for this.

tks & krgds, -nik

 

2 ACCEPTED SOLUTIONS
m_dekorte
Super User
Super User

Hi @hood2media 

 

If there's just that specific instance you need to change around. so your data is like this

m_dekorte_0-1684231863868.png

 

You could transform that, retaining other record fields, like so for example

m_dekorte_1-1684231931479.png

 

Copy this into a new blank query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJLLVeITE0sUghILCqpBAo45+fkpCaXZObnATkhqRUlhkqxOtFKRuhSGBpBao2UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Category = _t, Item = _t, Other = _t]),
    Transform = Value.ReplaceType(
        Table.FromRecords( List.Transform( Table.ToRecords( Source ), each 
            if _[Category] = "New Year Party" and _[Item] = "Collection" then _ & [Category="Collection", Item="New Year Party"] else _ )
        ), Value.Type(Source)
    )
in
    Transform

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

AjithPrasath
Resolver II
Resolver II

Hi, In that case , the replace value in power query editor will workans_1.PNG

 

Category= Table.ReplaceValue(#"Changed Type","Collection","NY Party",Replacer.ReplaceText,{"Category"})

Item= = Table.ReplaceValue(#"Replaced Value","NY Party","Collection",Replacer.ReplaceText,{"Item"})ans_1.PNG

 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

5 REPLIES 5
AjithPrasath
Resolver II
Resolver II

Hi, In that case , the replace value in power query editor will workans_1.PNG

 

Category= Table.ReplaceValue(#"Changed Type","Collection","NY Party",Replacer.ReplaceText,{"Category"})

Item= = Table.ReplaceValue(#"Replaced Value","NY Party","Collection",Replacer.ReplaceText,{"Item"})ans_1.PNG

 

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

m_dekorte
Super User
Super User

Hi @hood2media 

 

If there's just that specific instance you need to change around. so your data is like this

m_dekorte_0-1684231863868.png

 

You could transform that, retaining other record fields, like so for example

m_dekorte_1-1684231931479.png

 

Copy this into a new blank query.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUfJLLVeITE0sUghILCqpBAo45+fkpCaXZObnATkhqRUlhkqxOtFKRuhSGBpBao2UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Category = _t, Item = _t, Other = _t]),
    Transform = Value.ReplaceType(
        Table.FromRecords( List.Transform( Table.ToRecords( Source ), each 
            if _[Category] = "New Year Party" and _[Item] = "Collection" then _ & [Category="Collection", Item="New Year Party"] else _ )
        ), Value.Type(Source)
    )
in
    Transform

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

many tks to both @m_dekorte & @AjithPrasath.

i'll chk your solutions & revert as necessary.

 

krgds, -nik

 

AjithPrasath
Resolver II
Resolver II

In Power Query editor, You can change the column names of the respective column names. For ex: change the column name of the "Item" to " Collection" and vice-versa.

thanks @AjithPrasath.

actually, not all items r in that condition. only the wrong ones (based on above mentioned condition) that need correction.

krgds, -nik

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.