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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mora11
Helper I
Helper I

Static and dynamic columns in matrix together

Hello All,

Is there any way to create matrix visual with few levels of hierarchy in rows and with 5 static columns and another 5 dynamic columns that will be displayed based on slicer selection in cooperance with Analysis Services?

 

Is there a way to sort values for columns that are created using SWITCH statement?

 

Thanks,

10 REPLIES 10
Sergii24
Super User
Super User

Hi @mora11, you can use "Filed parameter" to achiveve desired result:

  1. Create Field parameter with 3 columns you want to select dynamically
  2. Create a table visual and add there 5 static columns
  3. Add the sixth column (your field parameter). 
  4. Add filter parameter as slicer to the canvas

Now when selecting any value of field parameter in slicer, the number of column will dymamically change from 6 to 8 columns (because if none value is seelcted by the field parameter, all values are selected, so min selection of the field parameter is 1 column).  

You can learn more about "Filed parameter" here - https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

Hey, thanks for that but unfortunately that solution will not work in my case as I need to show data calculated on the fly (I need to switch usung measures instead of columns). 😞

v-yanjiang-msft
Community Support
Community Support

Hi @mora11 ,

According to your description, I create a sample to test.

vyanjiangmsft_0-1686811296949.png

Here's my steps:

1.Create two tables.

Column table:

vyanjiangmsft_1-1686811387749.png

Slicer table:

vyanjiangmsft_2-1686811435410.png

2.Create a measure:

Measure =
SWITCH (
    MAX ( 'Column'[Column] ),
    "Static", SUM ( 'Table'[Value] ),
    SUM ( 'Table'[Value] ) * SELECTEDVALUE ( Slicer[Slicer] )
)

Get the result:

dynamic.gif

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

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

Yaaay, it is possible. Thanks. But, as I can see native sorting option for dynamic and static columns is disable in that case, right? Is there a way to enable it again?

Hi @mora11 ,

I'm not quite clear about what you mean "sorting option for dynamic and static columns". Do you mean sort the visual in More options>sort by>Columns?

vyanjiangmsft_0-1686815119403.png

If so, it doesn't make much sense, because values are sorted in the vertical direction。

Or if you want to sort the Column, for example in the above image, Static in the left and Dynamic in the right, simply add an index column in PowerQuery and select sort column by index.

vyanjiangmsft_1-1686817238342.png

Then get the result:

vyanjiangmsft_2-1686817272534.png

Best regards,

Community Support Team_yanjiang

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

Sorry for unclear description. Let's imagine that I have percentage values in the column (it doesn't matter if it is static or dynamic one). In regular matrix, report user can click on the column header and sort it descending. If user clicks again then values will be sorted ascending - it is regular PBI behaviour. Using dynamic columns in matrich, regular sorting option doesn't work at all (please check in PBIX that you shared). This is my case 🙂

Hi @mora11 ,

By my test, Columns in matrix can't be sorted even if static one. Below is a simple matrix with data from the same table. When I click each column, it can only highlight the column instead of sort the values.

vyanjiangmsft_0-1686905312237.png

Only the Rows "Sub-category" can do that.

vyanjiangmsft_1-1686905475822.png

Please confirm again. Thank you!

 

Best regards,

Community Support Team_yanjiang

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

Yes, this is exactly what I meant.

Hi @mora11 ,

Have you sorted the column in matrix in other sample but failed in this one?

 

Best regards,

Community Support Team_yanjiang

I would say that ability to sort columns in matrix visual is regular Power BI behaviour however it does not work with dynamic columns and this is why I am asking for advice.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors