cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SBuri Member
Member

Rename Nested Table Headers If Header Exists

Hey there,

 

I have a series of nested tables:

Data:

Table

Table

Table

Table

 

 

Using this formula I can rename nested table headers: 

Table.TransformColumns(LastAppliedStepName, {{"NameofColumnwithNestedHeaders", each Table.RenameColumns( _, {"Fleet", "Fleet2"})}})

 

However, if a table does not have the column "Fleet" then it produces an error - 

Data:

Table

Table

Error (does not have a column named "Fleet")

Table

Error (does not have a column named "Fleet")

 

Given that I need to rename multiple columns (more than just Fleet), how can I tell Power Query to just give me the table if a certain rename produces no change rather than throwing an error?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SBuri Member
Member

Re: Rename Nested Table Headers If Header Exists

I may have solved this via the following equation - 

Table.TransformColumns(ProperCaseHeaders, {{"Data", each Table.RenameColumns( _, {"Fleet", "Fleet2"}, MissingField.Ignore )}})

View solution in original post

1 REPLY 1
SBuri Member
Member

Re: Rename Nested Table Headers If Header Exists

I may have solved this via the following equation - 

Table.TransformColumns(ProperCaseHeaders, {{"Data", each Table.RenameColumns( _, {"Fleet", "Fleet2"}, MissingField.Ignore )}})

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 70 members 1,312 guests
Please welcome our newest community members: