Forum Discussion
Sorting a matrix second level - sort by column not working
Hi Captenaj
If you want to sort two columns in matrix.Sort by column cannot work well as it can only be used to sort by one column.
In my example,the first level (Item)-->Sort by total Numbers (DESC):120>60>30
Then the second level (Month)-->Sort by Month (ASC):Jan<Feb<Mar
If you just want to sort the second level.You may create a month table and use 'sort by column' for it.Attached file for your reference.
Regards,
Cherie
v-cherch-msft, thank you very much for your time. It may be sinking in finally.
Yes, I want to sort as you specify here: first by one parameter descending, then sort each of those groupings by a second parameter (which is a custom order) ascending. The questions/problems I am having are:
- Am I correct that if this is what I want to do, your Table3 isn't needed here?
- In the table that contains the data, I do not have a "MonthNo" column so I created it with an IF/THEN statement.
- The measure "Total Numbers" appears to add all the values in the Numbers column. What I want to do is sort the first column by number of rows, not by the value. How could I do that?
Thank you to all who have responed.
- v-cherch-msft7 years agoMicrosoft Employee
Hi Captenaj
- Am I correct that if this is what I want to do, your Table3 isn't needed here?
- In the table that contains the data, I do not have a "MonthNo" column so I created it with an IF/THEN statement.
Yes,correct.
There is no way to sort the first column by one parameter and the second column by a different parameter.To achieve your requirement,you may create a measure to get the sort and then sort by measure.
- The measure "Total Numbers" appears to add all the values in the Numbers column. What I want to do is sort the first column by number of rows, not by the value. How could I do that?
Change the total measure like below.Then you may get the sort.Please refer to attached file.
TotalRows = CALCULATE(COUNT(Table3[Items]),ALLEXCEPT(Table3,Table3[Items]))
Regards,
Cherie
- Captenaj7 years agoFrequent Visitor
Thank you. I am seeing the matrix sorted by Measure only. The first column is also sorted by measure so the order is B, A, C, not B, C, A as required. I think what your measure is doing is trying to calculate a value based on the Number and the MonthNo so we can sort only by that one value. Is there no way to sort subcategories? I have at least a thousand categories that I am going to be filtering but the "months" remains consistent. Can't I just somehow sort by MonthNo? Is there a better way to present the data than a matrix? Thank you again.
- v-cherch-msft7 years agoMicrosoft Employee