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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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 image :

The matrix contains Product and Value [Measure].

Raw Data

Madhu7624_0-1736849169932.png

 

Slicer :

Madhu7624_1-1736849220335.png

 

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

Madhu7624_2-1736849244682.png

 


Raw Data: 

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



slicer 

slicer
Year
2023
2024


Order needed 

Order Required [ when I select year in Slicer ]
20232024
Orderorder
P1P1
P2P2
P3P3
P6P12
P8

P14


@BeaBF 

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@Madhu7624 Ok, so create a custom column in Power Query with this code:

=Text.Middle([Product], 1, 3)
BeaBF_0-1736850253246.png

 

then load data and make Sort Product a Whole Number type:

BeaBF_2-1736850388229.png

 

Now click on Product column and choose this new one in "Sort by column"

BeaBF_1-1736850313815.png
 
It will be ordered as you want.
 
If it's ok please accept the answer as solution
 
BBF
 

View solution in original post

1 REPLY 1
BeaBF
Super User
Super User

@Madhu7624 Ok, so create a custom column in Power Query with this code:

=Text.Middle([Product], 1, 3)
BeaBF_0-1736850253246.png

 

then load data and make Sort Product a Whole Number type:

BeaBF_2-1736850388229.png

 

Now click on Product column and choose this new one in "Sort by column"

BeaBF_1-1736850313815.png
 
It will be ordered as you want.
 
If it's ok please accept the answer as solution
 
BBF
 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.