top of page

Excel Arena

This is the place, where we can test the boundaries of Excel functions.

2 Flexible Techniques for Renaming Columns in Power Query

The source data includes columns for Name and Month Number, ranging from 1 to 12. Our objective is to change the column name from Month Number to Month Name.

ree

In this post, I will illustrate two methods.


Method-1:

let

 Source = Excel.CurrentWorkbook(){[Name="data"]}[Content],

 Result = Table.TransformColumnNames(Source, (f) => if Text.Length(f) > 2 then f else Date.ToText(#date(2025, Number.From(f),1),"MMM"))

in

 Result


Method-2:

let

 Source = Excel.CurrentWorkbook(){[Name="data"]}[Content],

 ColNames = List.Transform(List.Skip(Table.ColumnNames(Source)), (f) => { f, Text.Start(Date.MonthName(#date(2025, Number.From(f),1)),3) }),

 Result = Table.RenameColumns(Source,ColNames)

in

 Result

Comments


  • LinkedIn
  • Facebook
  • Twitter
  • Instagram
bottom of page