Dynamic Column Headers in Power BI

This Power BI tutorial will help you work with Power BI Measure Dynamic Column Headers.

I recently worked on a Power BI report where I needed to change column names in a visual dynamically. I thoroughly read all the relevant articles and successfully implemented this article.

This tutorial will teach us how to change column headers dynamically in Power BI. Also, we will see how we can change the column names dynamically on Power BI visuals.

Dynamic Column Headers in Power BI

Here, we will see how to change the column headers dynamically in Power BI.

Suppose you have three Power BI measures (i.e., Total Sales, Total Profit, Total Unit Sold). When you select any measure in a slicer, the column headers dynamically change in a matrix visual.

For example, when I choose the Total Profit slicer, the column headers dynamically change to Total Profit in the visual [as shown in the left-side image]. Similarly, when I select Total Sales, the visual column headers dynamically display as Total Sales [as shown in the right-side image].

power bi dynamic measure based on slicer

To this, follow the below steps:

We have a SharePoint list (Finance Sample) that contains below columns with various data types:

ColumnData Types
ProductSingle line of text
SalesCurrency
ProfitCurrency
Unit SoldNumber
Power BI Matrix with Dynamic Column Heading

Now we see how to change dynamic column headers in Power BI Matrix. Follow the below steps.

1. Open Power BI Desktop and load the data. Then, you see the data set in the Data pane.

dynamic column headers in power bi matrix

2. Now, we create a measure in Power BI. To do this, click the New measure under the Home table.

Dynamic headers in Power BI

3. In the formula bar, click the below expression. Then click Commit.

Total Sales = SUM('Financial Sample'[ Sales])

Where

  • Total Sales = Name of the Measure
  • Financial Sample = Name of the Data set
  • Sales = Name of the Column
  • SUM = DAX function
How do I change column headers dynamically in Power BI

4. Similarly, create Total Profit, Total Units sold using the below Measure.

Total Profit = SUM('Financial Sample'[Profit])
Dynamic Column Headers in Power BI
Total Units Sold = SUM('Financial Sample'[Units Sold])
Power Bi Dynamic Column Headers

5. Click the Modeling tab -> click New parameter -> select Fields.

Matrix with Dynamic Column Heading in Power BI

6. Now, the Parameters page comes. Select What will your variable adjust? as Fields -> Give a Name(my case, Sales Data) -> Expand Financial Sample -> Check the Total Sales, Total Profit, and Total Units Sold -> Click Create button.

Power BI Matrix Dynamic Column Header

7. Now you see automatically a Power BI Slicer created check the below screenshot.

Dynamic column header in Power BI matrix

8. Under the Visualizations pane, click the Matrix visual. Then, drag the Product into Rows and Sales Data into the Values field.

dynamic column name by slicer selection in power bi

9. You may be confused because, in the matrix visual, we can see all values that are not our requirements.

Dynamic Column Name in Power BI Matrix Visuals

10. You see the result When you select an item in the slice. Check the screenshot below.

Power BI Measure Dynamic Column Headers

This is how Power BI measures dynamic column headers.

Power BI Change Column name Dynamically on Visuals

Now we see how to change the column name dynamically on visuals without DAX. To do this, follow the below steps.

We have a SharePoint list (Orders) that contains below columns with various data types:

ColumnData Types
Product NameSingle line of text
CitySingle line of text
CategorySingle line of text
SegmentSingle line of text
Sub-CategorySingle line of text
SalesCurrency
ProfitCurrency
power bi change column name in visual

I hope you open Power BI Desktop and load the data set.

1. Under the Home tab, click Transform data.

dynamic column headers in power bi dax

2. Click Add Column -> Expand Index Column -> Select From 1 in the Power Query Editor.

power Bi Change column name Dynamically on visuals

3. Now, one Index column is created in the Power Query Editor.

Power BI Dynamically Change Column Name

4. Right-click on the Orders -> Select Duplicate. Then, change Orders (2) to Orders Unpivot by double click.

power bi How to deal with changing column names

5. In the Order Unpivot table, remove all columns except Category, Sub-Category, Segment, and Index by clicking the column header and then Remove.

Make dynamic changing Header Name in power BI Martrix visual

6. Select three columns(Category, Sub-Category, Segment) by “ctrl+click” -> Click Transform tab -> Click Unpivot Columns.Then Click Close & Apply.

Dynamic Column header change in Power BI Visual

7. Under the Visualizations pane, click Slicer. Then, drag Attribute into Field.

Change Header row titles in Matrix Visual - Power BI

8. Under the Visualizations pane, click the Matrix visual. Then, drag City into Rows, Value into Columns, and Sales into the Value field.

Power Bi Change Column name Dynamically on Visuals

9. Under the Visualizations pane, click the Clustered column chart. Then, drag the Value into the X-axis and Profit and Sales into the Y-axis.

How to Change dynamic Column Name in Power BI Visual

10. You can observe the corresponding result when selecting an item in the slicer. Check the screenshot below.

power bi change column name dynamically on Chart

Now, I select Segment in the slicer. Check the screenshot below.

Power BI Dynamically Change Column names on Visuals

This is how Power BI changes column names dynamically on visuals.

Conclusion

Now, I hope if you get any similar requirements, Power BI Measure dynamic column headers, you can do it using the above example.

This tutorial taught us how to change Power BI Measure dynamic column headers. Additionally, we see Power BI change the column names dynamically on visuals.

Moreover, you may like some more Power BI articles: