Hi Ramya,
I found these two function that can be used to rename columns.
Table.RenameColumns()
Similar to selectcolumns() takes table, ([old column name],[New column name])
Syntax:
Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table
Ex:
Table.RenameColumns(Table.FromRecords({[CustomerNum=1, Name="Bob", Phone = "123-4567"]}), {"CustomerNum", "CustomerID"})
I took the examples from Power BI docs, refer here for more information on table.renamecolumns().
https://docs.microsoft.com/en-us/powerquery-m/table-renamecolumns
One more shortcut is to use SELECTCOLUMNS( )
It is used to add calculated columns to the table, you can provide an alias name while using selectcolumns().
Syntax:
SELECTCOLUMNS(<table>, <name>, <scalar_expression> [, <name>, <scalar_expression>]…)
In the above syntax, the name is the renamed column name and expression can be given as existing column or any expression.
Ex:
SELECTCOLUMNS (
Products,
"Full Name", Products[full_name],
"Last Name", Products[last_name]
)
Preparing for Power BI exam? Check out Power BI Course now!