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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Ignite190
Frequent Visitor

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 : 

 

Ignite190_0-1767779156560.pngIgnite190_1-1767779168292.pngIgnite190_2-1767779172034.png

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

 

 

1 ACCEPTED SOLUTION

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.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

8 REPLIES 8
v-sgandrathi
Community Support
Community 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.

danextian
Super User
Super User

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.

 

danextian_0-1767787722166.png

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]
    )

danextian_1-1767787810236.png

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.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.

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.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi Danextial , Thanks for your response . The problem with this solution is that I am unable to sort the columns which is also essential part of requirement . Could you provide a solution where I can also sort the column . Thanks alot for your help.

DanieleUgoCopp
Resolver III
Resolver III

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

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

cengizhanarslan
Super User
Super User

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.

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.