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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
learner03
Post Partisan
Post Partisan

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 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Jihwan_Kim
Super User
Super User

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.

 

Untitled.png

 

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]

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

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.

 

Untitled.png

 

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]

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


amitchandak
Super User
Super User

@amitchandak this gives me Non-Blanks at the top but do not sort by Earliest date in matrix

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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