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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
anshusaketsingh
Frequent Visitor

Dynamic sorting for matrix column headers based on Descending order of Measure

Hi Experts 

 

So I am using a field parameter as column and want it to sort dynamically based on distinct count of order ids. For eg, I want the below table to sort dynamically with Standard Class on left as it has highest order ids , followed by Second Class, First Class and then Same Day.

 

But it should dynamically change order based on order ids when I switch to Category or any other parameter.

I tried to create a dax to countd distinct ids and rankx to rank the dimensions but it is giving circular error.

Any help will be deeply appreciated.

Added a workbook with case scenerio for reference.

 

Superstore Reference Workbook.pbix

anshusaketsingh_0-1710965561455.png

 

Data Preview -

anshusaketsingh_0-1711012055023.png

 

3 REPLIES 3
ypannnn
Frequent Visitor

Hi @anshusaketsingh. Did you find a solution? I have encountered a similar issue and would really appreciate it if you could share how you solved it. Thank you!

v-jiewu-msft
Community Support
Community Support

Hi @anshusaketsingh ,

The link can’t be opened.

Please try the following methods:

1.Create the simple table.

vjiewumsft_0-1711004811407.png

2.Create the new column to sort desc.

 

Desc order = 
VAR stat = 'Table'[State]
RETURN
RANKX(
    FILTER('Table', 'Table'[State] = stat), 'Table'[ID], ,DESC, Skip
)

 

3.Drag the field into the matrix visual. Select the Class field, and choose sort by column feature and select new column.

vjiewumsft_1-1711004831461.png

vjiewumsft_2-1711004850028.png

4.The result is shown below.

vjiewumsft_3-1711004858289.png

Best Regards,

Wisdom Wu

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

Thanks a lot for your response @v-jiewu-msft 

The solution unfortunately doesn't seem to wirk because the ids are not unique as in your with my workbook.

Also its parameter rather than column that I am using.

Below is how my original data looks like -

anshusaketsingh_0-1711012204724.png

 

Attached the workbook too-

Superstore Reference Workbook.pbix

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.