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. I...
- 4 years ago
Thanks for the additional info.
See attached PBIX.
ronrsnfld
4 years agoSuper 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