Forum Discussion

Ignite190's avatar
Ignite190
Frequent Visitor
8 months ago
Solved

Adjust the column width dynamically based on the number of columns selected.

I am creating a matrix with multiple measure with multiple buckets Group A , Group B , Group C . In each group I have calculated measures A,B,C,D,E (BTS all have different calculations based of buckets) . I have given user the slicer to select multiple measure (A,B,C,D,E) . The issue is when users make selection of less than 5 measures it doesn't match with the bucket box (static) and not giving good user experience . Can anyone help with this : 

 

Expectation is to change width of each column based of no of selection so that they can come under respective bucket only.

 

 

  • In the display/disconnected table, you can just add another column whether the row is for actual, budget or difference and use that in a slicer.

8 Replies

  • Power BI cannot dynamically change column widths at runtime based on:

    • the number of measures selected

    • slicer selections

    • buckets / measure groups

    Matrix and table visuals use a static layout. Column width is calculated at render time and cannot respond to slicer-driven measure visibility.

  • Hello,

    I think you can fix it creating 3 different table (or matrix),
    because you can't keep the format of the column with one matrix.

    Best regards,
    Thank you

    • Ignite190's avatar
      Ignite190
      Frequent Visitor

      This would have been possible if there was only one column in Rows. However, in this case, there's a hierarchy in Rows.

  • Hi Ignite190 

    What you are trying to accomplish cannot be done using separate visuals. The visuals at the top have no awareness of the width or layout of the columns in the matrix below - they are static and their dimensions cannot be controlled with a measure. In addition, field parameter tables do not support hierarchies. A workable approach is to use a disconnected table that contains the measure names along with their groupings, and then create a measure that references those columns. If different formats are required, additional columns will be needed to store format strings, as well as a separate column to control sort order.

     

    Header Measures 01 = 
    VAR MeasureName =
        SELECTEDVALUE ( MHeaders[Measure Name] )
    RETURN
        SWITCH (
            TRUE (),
            MeasureName = "Leads Actual", [Leads_Actual],
            MeasureName = "Leads Budget"
                && SELECTEDVALUE ( MHeaders[Budget/Actual] ) = "DIFF", [Leads_Actual] - [Leads_Budget],
            MeasureName = "Leads Budget", [Leads_Budget],
            MeasureName = "Marketing Spend Actual", [Marketing_Spend_Actual],
            MeasureName = "Marketing Budget", [Marketing_Budget],
            MeasureName = "Revenue Actual", [Revenue_Actual],
            MeasureName = "Revenue Budget", [Revenue_Budget],
            MeasureName = "Conversions Actual", [Conversions_Actual],
            MeasureName = "Conversions Budget", [Conversions_Budget]
        )
    

    Note: Since there is only one measure and the hierarchy are essentially dimensions, sorting by a measure is not possible by clicking a header.

     

    Please see the attached sample pbix.

    • Ignite190's avatar
      Ignite190
      Frequent Visitor

      Hi danextian - Thanks for replying . I reviewed your dashboard but there is one thing missing from my requirement . User should be able to select if they want to see only Actuals/budget or Difference . Can you update your file and share with this functionality.

      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        In the display/disconnected table, you can just add another column whether the row is for actual, budget or difference and use that in a slicer.

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity Support

    Hi Ignite190,

     

    Because the matrix uses a disconnected table and a single dynamic measure, native column sorting from the visual header won't work, Power BI only lets you sort by fields actually shown in the visual, not by dynamically switched measures. To fix this, you can add a SortOrder column to the disconnected table and set Sort by Column in the model to control the column order. If you need dynamic sorting based on values, a possible workaround is to create separate ranking measures for each metric and use them in the row hierarchy for sorting. However, matrix columns can't be dynamically sorted when measures use a SWITCH pattern. So, it's best to manage the column order using a predefined sort column in the header table.

     

    Thank you.