Forum Discussion
Double sort in Matrix
How can I sort with the criteria as Arrivl Date Asc to Desc with non-blanks on top an then second sort by Alternate column from Ase to Desc Date.
it is a matrix visual
| Arrive date | Alternate |
| 22/02/2022 | |
| 24/02/2022 | |
| 21/02/2022 | 25/02/2022 |
| 21/02/2022 | |
| 24/02/2022 | |
| 24/02/2022 | 24/02/2022 |
| 23/02/2022 | 23/02/2022 |
| 24/02/2022 | |
| 24/02/2022 | 17/02/2022 |
| 23/02/2022 | 15/02/2022 |
| 23/02/2022 | 21/02/2022 |
| 23/02/2022 | |
| 25/02/2022 | |
| 17/02/2022 | 18/02/2022 |
| 18/02/2022 | 18/02/2022 |
| 24/02/2022 | 18/02/2022 |
| 25/02/2022 | |
| 25/02/2022 | |
| 18/02/2022 | 21/02/2022 |
| 25/02/2022 | |
| 25/02/2022 | |
| 17/02/2022 | 18/02/2022 |
| 25/02/2022 |
Hi learner03 ,
According to your description, the best way to sort the reference is as follows: you can create a column and use the result of the rankx function as the index.
Column = IF('Table'[Arrive date]=BLANK(),1,2)Col_rank = RANKX ( 'Table', RANKX ( 'Table', 'Table'[Column],, ASC ) * 1000 + RANKX ( 'Table', 'Table'[Alternate],, DESC, DENSE ) )
If the problem persists, please point out the specific error and provide a screenshot of the expected results. Looking forward to your feedback.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 Replies
- OwenAuger
Super User
Hi learner03
In a matrix, nesting is handled automatically, so I would suggest creating sort by columns for these two columns.
I wasn't quite clear on the sort order - did you mean that for both columns, the most recent dates should appear first?
For such sorting, I would created columns (in Power Query) that are the negative of the original date (possibly with a constant added), but map null values to zero.
e.g. for Arrive date, the sort column could be:
if [Arrive date] = null then 0 else -Number.From([Arrive date])Then set Arrive date to sort by this column in the model.
Similarly for Alternate.
Regards,
Owen
- amitchandak
Super User
learner03 , Is there an opportunity is fill up or fill down in power Query ?
https://docs.microsoft.com/en-us/power-query/fill-values-column
Then we can use stepped layout off
- learner03
Post Partisan
amitchandak I can't fiill up/down with any dates as the empty ones are based on when the product reaches. So, if we do not know when the product will reach, then it will by empty field.
- v-henryk-mstf
Community Support
Hi learner03 ,
According to your description, the best way to sort the reference is as follows: you can create a column and use the result of the rankx function as the index.
Column = IF('Table'[Arrive date]=BLANK(),1,2)Col_rank = RANKX ( 'Table', RANKX ( 'Table', 'Table'[Column],, ASC ) * 1000 + RANKX ( 'Table', 'Table'[Alternate],, DESC, DENSE ) )
If the problem persists, please point out the specific error and provide a screenshot of the expected results. Looking forward to your feedback.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.