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
ValeriaBreve
Post Partisan
Post Partisan

Replace Column Names through a mapping table

Hello,

I am trying to replace the column names in my table with new columns names coming from a previous step.

In practice, I have an initial table with column names, a second table with 2 columns - one the original column name as found in the original table, and the other one is the replacement.

 

ValeriaBreve_1-1679901416903.png

 

So in my final query, the column called "2023 +1Q1" should be replaced with "2024 Q1".

I think I need to use Table.TransformColumnNames, but I can't come up with the right way.... or maybe there is a different way?

 

Thanks!

Kind regards

Valeria

 

 

 

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

Hello, @ValeriaBreve use Table.RenameColumns. It accepts a list of column name pairs (list of lists {"old", "new"}) as a parameter.

let
    original = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJWitWJVjICskyUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"2023+1Q1" = _t, #"2023+1Q2" = _t]),
    second = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY2DDRU0gExTRSArFgduLARXNhIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Original = _t, Final = _t]),

    renames = List.Zip( Table.ToColumns( second )),
    final = Table.RenameColumns( original, renames)

in
    final

View solution in original post

2 REPLIES 2
ValeriaBreve
Post Partisan
Post Partisan

Thanks!!!! works perfectly 🙂 I learned something today 🙂

AlienSx
Super User
Super User

Hello, @ValeriaBreve use Table.RenameColumns. It accepts a list of column name pairs (list of lists {"old", "new"}) as a parameter.

let
    original = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJWitWJVjICskyUYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"2023+1Q1" = _t, #"2023+1Q2" = _t]),
    second = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtY2DDRU0gExTRSArFgduLARXNhIKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Original = _t, Final = _t]),

    renames = List.Zip( Table.ToColumns( second )),
    final = Table.RenameColumns( original, renames)

in
    final

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.

Top Kudoed Authors