cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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 )}})

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 )}})

Helpful resources

Announcements
Community Highlights

Community Highlights

Find out what's new in the Power BI Community!

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 365 members 4,136 guests
Please welcome our newest community members: