Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Soc3
Frequent Visitor

Dynamic column header in table based on values in one field

I have a text field in a table that I’m displaying the count for. The column name is Details, and the data in this column is either Stationary or Mobile. I have a slicer for the same field to show the count of the two results (stationary vs mobile).

 

Stationary
Mobile
Stationary
Stationary
Mobile

 

Count: 3 when stationary is selected in slicer
Count: 2 when mobile is selected in slicer

 

How do I dynamically change the column header in my table instead of Details to be Count of Stationary or Count of Mobile?

Is there a way to do this without creating separate measures to count each stationary and mobile values?

5 REPLIES 5
Ray_Minds
Responsive Resident
Responsive Resident

Hi @Soc3 

Yes, you can dynamically change the column header in Power BI without creating separate measures for counting Stationary and Mobile. You can achieve this using a Measure and a Field Parameter. 

Steps: 

  1. Create a Measure for Dynamic Column Header: 

Ray_Minds_0-1739960726877.png

 

 

This measure will return "Count of Stationary" when "Stationary" is selected in the slicer and "Count of Mobile" when "Mobile" is selected. 
2. Create a Measure for Count: 

Ray_Minds_1-1739960726878.png

 

 

 
3.  Add the Measures to Your Table Visual: 

Use DynamicColumnHeader as the column header. 

Use CountSelected as the column values. 

 

Since DynamicColumnHeader changes based on the slicer selection, the table will update dynamically. 

 

When Mobile is selected: 

Ray_Minds_0-1739960910906.png

 

 

 

 

 

When Stationary is selected: 

 

 

Ray_Minds_1-1739960938164.png

Best regards,
Ray Minds
http://www.rayminds.com
https://www.linkedin.com/company/rayminds/

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Ray_Minds ,

 

Thanks for your reply. I was hoping to accomplish this in a table instead of a matrix. Do you know how to implement in a table specifically where I can't differentiate between a column and a value?

Ritaf1983
Super User
Super User

Hi @Soc3 
You can use matrix instead of table and this is how it works as a default :

Ritaf1983_0-1739938599206.pngRitaf1983_1-1739938616711.png

The pbix is attached

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
(Virus scan in progress ...)

Hi @Ritaf1983 ,

 

Thanks for your reply. 

 

I have multiple values to include in the matrix and when I add those values, the column header gets bumped up a level. 

 

Soc3_0-1739974861972.png

Soc3_0-1740009890680.png

 

I've changed the terms, Detail=Advanced Booking Status and Stationary/Mobile are Advanced Purchase and Not in Advance. How do I associate the dynamic column header with the Count value?

Hi again
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements