Forum Discussion
Anonymous
4 years agoNot applicable
Rename some columns by adding a prefix
Hi everyone.
I have some tables with aprox. 40 columns. I would like to rename some of these columns by adding a prefix. I have tried Table.PrefixColumns but this adds a prefix to all the columns. Is there a way to achieve this only in some columns?
Thanks a lot
Thanks for the additional info.
See attached PBIX.
7 Replies
- ronrsnfldSuper User
- Create a list of the columns you want to prefix
- List.Transform => create a "Rename List".
- Table.RenameColumns
Code Example:
let tbl = Table.FromColumns( {{"a","B","C","D","E"}, {"F","G","H","I","J"}, {"K","L","M","N","O","P"}, {"Q","R","S","T","U"}, {"F","G","H","I","J"}, {"K","L","M","N","O","P"}} ), #"Columns to Prefix" = {"Column2", "Column4", "Column6"}, Prefix = "Old.", Renames = List.Transform(#"Columns to Prefix", each {_, Prefix & _}), #"Prefix Some" = Table.RenameColumns(tbl, Renames) in #"Prefix Some"Before
After
- KNPSuper User
Probably, which columns?
Please provide sample data.
- AnonymousNot applicable
Hi, basically I want to achieve this:
All columns but ITEM, get the prefix "CANT" in their name
- KNPSuper User
- AnonymousNot applicable
Guys, you are awesome.