s.turn
s.turn

Reputation: 71

After Table.TransformColumnNames, why do column names revert back to previous names in subsequent steps?

I have a line in my code which transforms my column names to upper case:

#"Renamed Columns3" = Table.TransformColumnNames(Source, Text.Upper),

This works fine when it's the last step in the code.

However, when I add the following section, the column headers revert back to their previous randomly-cased form.

Index= Table.AddIndexColumn(Source, "Index", 0, 1),
EmailList= List.Select(Table.ColumnNames(Index), each Text.Contains(_, "EMAIL_OPTIN")),   
Merged = Table.CombineColumns(Index,EmailList,Combiner.CombineTextByDelimiter("", QuoteStyle.None),"MergedE"),
#"Merged Queries" = Table.NestedJoin(Index,{"Index"},Merged,{"Index"},"MergedE",JoinKind.LeftOuter),
#"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "MergedE", {"MergedE"}, {"MergedE"}),
#"Removed Columns3" = Table.RemoveColumns(#"Expanded Table2",{"Index"})
in  #"Removed Columns3"

As you can probably guess, the reason I am upper-casing the column names in the first place is so that the following step can identify all columns with the right names (i.e. containing "EMAIL_OPTIN") - the original source data has a variety of capitalisation, and this seemed to be preventing the above step from merging all the relevant columns.

Any idea why the upper-casing disappears? It seems to happen before the column merging even takes place, as only the (originally) upper-case columns are being merged, and those that were originally in lower-case or sentence-case are still left out.

Upvotes: 0

Views: 291

Answers (1)

Aleksei Zhigulin
Aleksei Zhigulin

Reputation: 1634

When you add new section of code you don't refer to step with renaming headers. Instead you refer to Source step (i.e. table with headers before renaming). Just change this line:

Index = Table.AddIndexColumn(#"Renamed Columns3", "Index", 0, 1)

Upvotes: 1

Related Questions