Forum Discussion

learner03's avatar
learner03
Post Partisan
4 years ago
Solved

Triple date sort in Matrix

How can do triple sort for below based on all date ascending (ignoring Blank) in below order-

1st by Date try 1 (Ascending to descending with Non-blanks on top)

2nd by Date try 2( Ascending to descending with Non-blanks on top)

3rd by Date try 3( Ascending to descending -this will always hve some date populated)-

 

When I make a sort measure and put that in the matrix, it gives blanks on the top if I do Ascending to Descending.

Input Data

 

Date try 3Date try 1Date try 2
1/07/20227/07/20227/07/2022
25/06/20226/07/20221/07/2022
25/06/20221/07/202230/06/2022
28/06/2022 8/07/2022
18/06/2022 27/06/2022
25/06/20227/07/20221/07/2022
25/06/20226/07/20221/07/2022
1/07/20226/07/20227/07/2022
1/07/202230/06/20227/07/2022
28/06/2022 8/07/2022
28/06/2022 8/07/2022
23/06/20228/07/202230/06/2022
28/06/20228/07/202214/07/2022
1/07/20228/07/20227/07/2022
1/07/20222/07/20227/07/2022
30/06/20226/07/202213/07/2022
1/07/2022  
3/07/2022  
1/07/2022  
1/07/2022 18/07/2022
21/06/2022 27/06/2022
5/07/2022 11/07/2022
29/06/2022 7/07/2022
29/06/2022 7/07/2022
1/07/2022 7/07/2022
6/07/2022  
6/07/2022  
25/07/2022  
13/07/2022  
13/07/2022  
3/08/2022  
17/07/2022  
17/07/2022  
13/07/2022  
12/07/2022  
12/07/2022  
12/07/2022  

 

Outpur requied

Date try 3Date try 1Date try 2
1/07/202230/06/20227/07/2022
25/06/20221/07/202230/06/2022
1/07/20222/07/20227/07/2022
25/06/20226/07/20221/07/2022
25/06/20226/07/20221/07/2022
1/07/20226/07/20227/07/2022
30/06/20226/07/202213/07/2022
25/06/20227/07/20221/07/2022
1/07/20227/07/20227/07/2022
23/06/20228/07/202230/06/2022
1/07/20228/07/20227/07/2022
28/06/20228/07/202214/07/2022
18/06/2022 27/06/2022
21/06/2022 27/06/2022
29/06/2022 7/07/2022
29/06/2022 7/07/2022
1/07/2022 7/07/2022
28/06/2022 8/07/2022
28/06/2022 8/07/2022
28/06/2022 8/07/2022
5/07/2022 11/07/2022
1/07/2022 18/07/2022
1/07/2022  
1/07/2022  
3/07/2022  
3/07/2022  
6/07/2022  
6/07/2022  
8/07/2022  
12/07/2022  

OwenAuger 

  • Hi,

    I am not sure if I understood your data model correctly.

    I assume you have a kind of index column that differenciates a row that has the same information with other row.

    Please check the below picture and the attached pbix file.

    I created a sort column inside the table, and showed it toghether in a table visualization.

     

     

    Sort by condition CC =
    IF (
        Data[Date try 1] = BLANK (),
        0,
        RANKX (
            FILTER ( Data, Data[Date try 1] <> BLANK () ),
            INT ( Data[Date try 1] ),
            ,
            DESC
        )
    ) * 1000000 + Data[Index]
        + IF (
            Data[Date try 2] = BLANK (),
            0,
            RANKX (
                FILTER ( Data, Data[Date try 2] <> BLANK () ),
                INT ( Data[Date try 2] ),
                ,
                DESC
            )
        ) * 10000 + Data[Index]
        + RANKX (
            FILTER ( Data, Data[Date try 3] <> BLANK () ),
            INT ( Data[Date try 3] ),
            ,
            DESC
        ) * 100 + Data[Index]
    

3 Replies

  • Hi,

    I am not sure if I understood your data model correctly.

    I assume you have a kind of index column that differenciates a row that has the same information with other row.

    Please check the below picture and the attached pbix file.

    I created a sort column inside the table, and showed it toghether in a table visualization.

     

     

    Sort by condition CC =
    IF (
        Data[Date try 1] = BLANK (),
        0,
        RANKX (
            FILTER ( Data, Data[Date try 1] <> BLANK () ),
            INT ( Data[Date try 1] ),
            ,
            DESC
        )
    ) * 1000000 + Data[Index]
        + IF (
            Data[Date try 2] = BLANK (),
            0,
            RANKX (
                FILTER ( Data, Data[Date try 2] <> BLANK () ),
                INT ( Data[Date try 2] ),
                ,
                DESC
            )
        ) * 10000 + Data[Index]
        + RANKX (
            FILTER ( Data, Data[Date try 3] <> BLANK () ),
            INT ( Data[Date try 3] ),
            ,
            DESC
        ) * 100 + Data[Index]