top of page
Antares Studio Games Icon_Small.png

The Antares Alien

Power BI   |  Game Development

  • Writer's pictureBrent Jones

Convert Column Names to Lowercase (or Uppercase) in Power Query

To convert your column names/headers to lowercase, use this Power Query custom function.


(yourTable as table) as table =>
let
    #"Table Column Names" = 
        Table.ColumnNames(yourTable),

    #"Convert list to table" = 
        Table.FromList(
            Table Column Names, 
            Splitter.SplitByNothing(), 
            null, 
            null, 
            ExtraValues.Error),
    
    #"Add column for lowercase name" = 
        Table.AddColumn(
            #"Convert list to table", 
            "lowercased", 
            each Text.Trim(Text.Lower([Column1]))),
    
    #"Convert the record to a list" = 
        Table.AddColumn(
            #"Add column for lowercase name", 
            "tolist", 
            each Record.ToList(_)),
    
    #"Convert the column of lists to a list" = 
        #"Convert the record to a list"[tolist],
        
    #"Rename Columns to Lowercase" = 
        Table.RenameColumns(
            yourTable,
            #"Convert the column of lists to a list")
in
    #"Rename Columns to Lowercase"


 

Alien says... If you're not sure what custom functions are, don't worry! It's simple. Just create a new blank query, open the advanced editor, and copy and paste the code in. Then rename the query to whatever you want. In my case, I called it "ConvertColumnsToLowerCase".




 

To use it, simply pass in your table into the function:

Now all your column headers are lowercase! If you want uppercase or proper case, change the code on line 18 from Text.Lower() to Text.Upper(), or Text.Proper().


There may be other ways to accomplish lowercase conversion, but this is how I did it. Enjoy!



Komentarai


  • Facebook
  • Twitter
  • Instagram
bottom of page