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
aoliver
Helper III
Helper III

Conditional Renamed Columns

Hi everyone

It is possible to change the name of a column in powerQuery depending of the previous name? 
I am trying it in advance editor but I cant reach a solution of this, an example would be very apreciated.

 

Thanks in advance,

 

4 REPLIES 4
aoliver
Helper III
Helper III

Any ideas? 

Greatings

@aoliver  You can try unpivoting the columns and then replace the values under Attribute field from FirstName to SecondName, then finally pivot the table again.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




PattemManohar
Community Champion
Community Champion

@aoliver  Could you please provide an example to understand exactly about your requirement.





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




let
Source = Table.Combine({#"tempAmb(DateStart)",#"tempAmb(DateEnd)"}),

- Here, i want to check if there is a column with the name:"firstName"

#"Renamed Columns" = Table.RenameColumns(Source,{{"firstName", "secondName"}})
in
#"Renamed Columns"

 

So, if the query has a column called "firstName" it will be call "secondName" at the end.

I'll hope that this example would be enough to understand the problem, if not, I can write pseudocode @PattemManohar 

Thanks 

 

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.