Forum Discussion

Soc3's avatar
Soc3
Icon for Helper I rankHelper I
1 year ago

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

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

    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

  • Ray_Minds's avatar
    Ray_Minds
    Icon for Solution Supplier rankSolution Supplier

    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: 

     

     

    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: 

     

     

     
    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: 

     

     

     

     

     

    When Stationary is selected: 

     

     

    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.

    • Soc3's avatar
      Soc3
      Icon for Helper I rankHelper I

      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?