Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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
Solved! Go to Solution.
Thanks for the additional info.
See attached PBIX.
| Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Guys, you are awesome.
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
Probably, which columns?
Please provide sample data.
| Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Hi, basically I want to achieve this:
All columns but ITEM, get the prefix "CANT" in their name
With that information, you can modify what I wrote by creating the list appropriately by changing two lines: (replace "tbl" with the appropriate table reference
#"Columns to Prefix" = List.RemoveMatchingItems(Table.ColumnNames(tbl),{"ITEM"}),
Prefix = "CANT",
Thanks for the additional info.
See attached PBIX.
| Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Thank you. It worked really good.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |