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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Madhu7624
Regular Visitor

Sorting Matrix Data Based on Slicer Selection

Hi Everyone,

I want to sort the data in a matrix in a specific order. When I select a value in the slicer.

Below is the raw data:

The matrix visual contains Product and Value [Measure].

Raw Data

Madhu7624_0-1736832684532.png

 

Slicer 

Madhu7624_2-1736832724588.png

 



The order in which the products need to be sorted depends on the year value selected in the slicer.

Madhu7624_1-1736832694720.png




Raw Data : 

Table
ProductYearValue
P32023100
P22023200
P12023300
P8202340
P62023100
P12024200
P32024300
P2202440
P142024100
P122024200


slicer : Year 
2023
2024

Required order, when we click on slicer : 

Order Required
20232024
Orderorder
P1P1
P2P2
P3P3
P6P12
P8P14





1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Madhu7624 ,

 

Thanks for the reply from BeaBF .

 

First, create a calculated column to extract the number of products.

ProductNumber = 
VALUE(
    MID('Table'[Product],2,2)
)

 

Then, create a calculated column to sort the numbers.

Order = 
RANKX(
    FILTER(
        'Table',
        'Table'[Year] = EARLIER('Table'[Year])
    ),
    'Table'[ProductNumber],
    ,
    ASC,
    DENSE
)

 

Please create a matrix visual object for display. Drag Oder to the rows, Year to the columns, and Product to the values. the final visual is shown below:

vhuijieymsft_0-1736906381383.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Madhu7624 ,

 

Thanks for the reply from BeaBF .

 

First, create a calculated column to extract the number of products.

ProductNumber = 
VALUE(
    MID('Table'[Product],2,2)
)

 

Then, create a calculated column to sort the numbers.

Order = 
RANKX(
    FILTER(
        'Table',
        'Table'[Year] = EARLIER('Table'[Year])
    ),
    'Table'[ProductNumber],
    ,
    ASC,
    DENSE
)

 

Please create a matrix visual object for display. Drag Oder to the rows, Year to the columns, and Product to the values. the final visual is shown below:

vhuijieymsft_0-1736906381383.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

@Anonymous Yes but the RANKX is significantly more computationally expensive and resource-intensive compared to a simple sort by column operation, I recommend to use my process.

 

BBF

BeaBF
Super User
Super User

@Madhu7624 Hi! Can you paste your data so that i can copy them to my power bi?

 

BBF

i have  attached in question 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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