Forum

Rename last column
 
Notifications
Clear all

Rename last column

3 Posts
2 Users
0 Reactions
668 Views
(@lanser)
Posts: 61
Estimable Member
Topic starter
 

Hi I am trying to rename the last column I can't do it the normal way because the source files have a varying number of columns but the total is always last.

I get a syntax error asking for a comma to replace the } in red if I replace it I get a Token Literal  expected error can't see what I am doing wrong 

 

#"Renamed Columns3" = Table.RenameColumns(#"Renamed Columns2",{List.Last(Table.ColumnNames(#"Renamed Columns2"), "Total"}})

 
Posted : 26/05/2021 11:17 am
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

Hello,

It is always easier if there is a sample file, I will give it a try anyway. I am replying this from my tablet, so can’t double check in Power Query how it should be, just viewing your M code.

Seems you are missing one or two brackets. As trying to show below, you are missing one right round bracket, but you also have a mismatch on the number of square brackets.
#"Renamed Columns3" = Table.RenameColumns(#"Renamed Columns2",{List.Last(Table.ColumnNames(#"Renamed Columns2"), "Total"}})

Br,
Anders

 
Posted : 26/05/2021 3:48 pm
(@lanser)
Posts: 61
Estimable Member
Topic starter
 

Thanks Anders, I missed counting the brackets, end result was a missing { and a missing )

in case anyone else is looking and want to rename the last column

= Table.RenameColumns(#"Renamed Columns2",{{List.Last(Table.ColumnNames(#"Renamed Columns2")), "Total"}})

 
Posted : 27/05/2021 9:46 am
Share: