Forum Discussion

Madhu7624's avatar
Madhu7624
Regular Visitor
1 year ago
Solved

"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

 

Slicer :

 

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

 


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 

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

    =Text.Middle([Product], 1, 3)

     

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

     

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

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

1 Reply

  • BeaBF's avatar
    BeaBF
    Super User

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

    =Text.Middle([Product], 1, 3)

     

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

     

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

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