Forum Discussion

kaweckil's avatar
kaweckil
New Member
2 years ago
Solved

Get column headers to dynamically fit to frame

Hi,

 

I wanted to see if the column headers in a matrix could be set to fit to a frame dynamically? The number of column headers depends on a slicer. I want the column headers to fill the frame of the matrix at all times.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, kaweckil 

    Based on your description, I've created the following sample data:

    I've created the following measures:

    Actuals1 = SUM(SalesData[Actuals])
    Budgets1 = SUM(SalesData[Budgets])
    Forecasts1 = SUM(SalesData[Forecasts])
    Var_Act_vs_Fcst = [Actuals1] - [Forecasts1]
    Var_Act_vs_Bud = [Actuals1] - [Budgets1]
    

    To be able to dynamically change the matrix header based on the slicer selection, I created the following header table:

    I use the following DAX expression to create a measure that toggles the measure for the corresponding matrix header:

    MatrixValues = 
    SWITCH(
        MAX(Mappings[TableHeaders]),
        "Actual", [Actuals1],
        "Budget", [Budgets1],
        "Forecast", [Forecasts1],
        "Var Act vs Fcst", [Var_Act_vs_Fcst],
        "Var Act vs Bud", [Var_Act_vs_Bud]
    )

    I've created a matrix with these fields, and a slicer with the TableHeaders field:

    When I select the corresponding title in the slicer, the title of the matrix also changes automatically:

    I have provided the PBIX file used this time below for your reference. In addition, you can learn about the current method of dynamically switching matrix headers through the following link:

    Solved: Dynamically changing matrix column headers based o... - Microsoft Fabric Community

    Solved: Dynamic Column Names for Matrix Visual using Slice... - Microsoft Fabric Community

    Dynamic Column Headers in Power BI Customize with Inforiver

     

     

    Best Regards

    Jianpeng Li

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

     

     

     

     

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, kaweckil 

    Based on your description, I've created the following sample data:

    I've created the following measures:

    Actuals1 = SUM(SalesData[Actuals])
    Budgets1 = SUM(SalesData[Budgets])
    Forecasts1 = SUM(SalesData[Forecasts])
    Var_Act_vs_Fcst = [Actuals1] - [Forecasts1]
    Var_Act_vs_Bud = [Actuals1] - [Budgets1]
    

    To be able to dynamically change the matrix header based on the slicer selection, I created the following header table:

    I use the following DAX expression to create a measure that toggles the measure for the corresponding matrix header:

    MatrixValues = 
    SWITCH(
        MAX(Mappings[TableHeaders]),
        "Actual", [Actuals1],
        "Budget", [Budgets1],
        "Forecast", [Forecasts1],
        "Var Act vs Fcst", [Var_Act_vs_Fcst],
        "Var Act vs Bud", [Var_Act_vs_Bud]
    )

    I've created a matrix with these fields, and a slicer with the TableHeaders field:

    When I select the corresponding title in the slicer, the title of the matrix also changes automatically:

    I have provided the PBIX file used this time below for your reference. In addition, you can learn about the current method of dynamically switching matrix headers through the following link:

    Solved: Dynamically changing matrix column headers based o... - Microsoft Fabric Community

    Solved: Dynamic Column Names for Matrix Visual using Slice... - Microsoft Fabric Community

    Dynamic Column Headers in Power BI Customize with Inforiver

     

     

    Best Regards

    Jianpeng Li

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