Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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!

  • Anonymous's avatar
    Anonymous
    8 years ago

    I may have solved this via the following equation - 

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    I may have solved this via the following equation - 

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