Forum Discussion
Dynamically Rename 1st Column
I am trying to dynamically rename the 1st column from whatever its Number value is to just "Column1"
From here i use = Table.ColumnNames(#"Promoted Headers") to get the column names as a list.
From there i only want the first item in the list so i use List.FirstN(Custom1,1) and that gets me the 1st item which is the first column name
Now i want to rename that column in the #"Promoted Headers" table/step so i tried
= Table.RenameColumns(#"Promoted Headers", #"Kept First Items", Column1) and this is what i get
Not sure if i am using the function incorrectly some help would be great.
And here is the Mcode
#"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table5", [PromoteAllScalars=true]),
Custom1 = Table.ColumnNames(#"Promoted Headers"),
#"Kept First Items" = List.FirstN(Custom1,1),
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items", Column1),
Thank you,
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items"&{“Column1"})
3 Replies
- cflynn_29Helper I
Got a slightly new error here, is it because the original column name is being represented as a number and not a text value?
- wdx223_DanielCommunity Champion
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items"&{“Column1"})