How to rename a column using DAX in Power BI?

0 votes
Is it possible to rename a column using DAX in Power BI? Can someone explain with example.
Aug 21, 2019 in Power BI by ramya
5,290 views

1 answer to this question.

0 votes

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]
)
answered Aug 21, 2019 by anonymous
• 32,490 points

Related Questions In Power BI

0 votes
1 answer
0 votes
1 answer

How to sum a data table in Power BI?

It's a good practice if you avoid ...READ MORE

answered May 17, 2019 in Power BI by avantika
• 1,500 points

edited May 17, 2019 by Omkar 2,681 views
0 votes
1 answer

How to use a gateway in Power Bi?

Follow the below procedure - 1. Install ...READ MORE

answered Oct 29, 2019 in Power BI by rachael
145 views
0 votes
1 answer

How to create a relative data slicer in Power BI?

Hi, With the relative date slicer or filter, you ...READ MORE

answered Jan 31 in Power BI by Shivani
454 views
+3 votes
2 answers

Combine tables in Power BI

You can also achieve this using a ...READ MORE

answered Oct 5, 2018 in Power BI by lina
• 8,220 points

edited Oct 11, 2018 by Kalgi 627 views
0 votes
1 answer

Power Bi Dax Table

You need to wrap the numbers in ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 51,950 points
249 views
0 votes
2 answers

Power BI Dax Multiple IF AND Statements

HI I have Column Patient 12 13 14 15 18 IN Patient=12, 13 Out ...READ MORE

answered May 22, 2019 in Power BI by VNK
15,056 views
0 votes
1 answer

Distinct count filtered by condition using Power BI Dax

Try this, it should work: DistinctCountActiveMonths = CALCULATE( ...READ MORE

answered Oct 5, 2018 in Power BI by Kalgi
• 51,950 points
22,628 views
0 votes
1 answer

How to Install Power BI in Windows

Hi, Anitha Go to this Link https://powerbi.microsoft.com/en-us/downloads/ Then click on ...READ MORE

answered Feb 28, 2019 in Power BI by Cherukuri
• 32,490 points
106 views
0 votes
1 answer

How to create final table based on Joins of two tables in power BI?

Hi Nithin, It is easy and simple. 1. Go ...READ MORE

answered Mar 1, 2019 in Power BI by Cherukuri
• 32,490 points
8,164 views