Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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,
Solved! Go to Solution.
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items"&{“Column1"})
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items"&{“Column1"})
Hi @cflynn_29 ,
well done, you are on the right path here. Just put the new name into quotes ("") like so:
Custom2 = Table.RenameColumns(#"Promoted Headers", #"Kept First Items", "Column1"),
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Got a slightly new error here, is it because the original column name is being represented as a number and not a text value?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
9 | |
8 | |
7 | |
7 |