Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
All,
I have a set of data that shows Sales by Group by Year. I have the matrix arranges wil the row set as Group with Years nested. I have the values as Sales amount. Here is the requirement. I need to sort the Group level in descending order by the subtotal and the Years under each group in date order. I cannot figure out how to mix the sorting to make this happen. When I sort the Sales in descending order, the Years are out of sequence. There is a picture of the original structure, the sorted by sales descending and what I actually need to get...
Any insights into making this happen is super helpful.
Thanks
| Original matrix | Sort desc by Sales | Required sort | |||||
| Gross Sales | Gross Sales | Gross Sales | |||||
| Group 1 | 600000 | Group 2 | 750000 | Group 2 | 750000 | ||
| 2020 | 100000 | 2022 | 400000 | 2020 | 200000 | ||
| 2021 | 300000 | 2020 | 200000 | 2021 | 150000 | ||
| 2022 | 200000 | >>> | 2021 | 150000 | >>> | 2022 | 400000 |
| Group 2 | 750000 | Group 1 | 600000 | Group 1 | 600000 | ||
| 2020 | 200000 | 2021 | 300000 | 2020 | 100000 | ||
| 2021 | 150000 | 2022 | 200000 | 2021 | 300000 | ||
| 2022 | 400000 | 2020 | 100000 | 2022 | 200000 | ||
| Group 3 | 500000 | Group 3 | 500000 | Group 3 | 500000 | ||
| 2020 | 125000 | 2022 | 250000 | 2020 | 125000 | ||
| 2021 | 125000 | 2020 | 125000 | 2021 | 125000 | ||
| 2022 | 250000 | 2021 | 125000 | 2022 | 250000 |
I think I understand but when I add the Variable for CurrentGroup the way you suggest the column returns with a circular reference error. Maybe this is not supported in DirectQuery Mode?
Hi @SWhiteMKL,
There are limitations/ restrictions when using DirectQuery in Power BI, including limitations to DAX logic, but I am not sure if that is the case here. Could you please share a few more details about the error you are getting, including screenshots, maybe I would be able to help better.
Also check out the following blog to learn more about DAX and DirectQuery.
https://blog.crossjoin.co.uk/2017/05/09/dax-functions-directquery-and-unrestricted-measures/
Proud to be a Super User! Regards, Bipin Lala | Business Intelligence Developer | |
Hi @SWhiteMKL,
I was able to achieve the required sorting in your Matrix Visual, though it was not as forward as expected. This is because Matrix Visual in Power BI does not allow multiple sort columns as the table visual does. You would only be able to sort either by Sales values or by Groups/ Years at a time, as experimented and shown by you as well.
To achieve the required sorting shown below, follow the steps -
Group Sum =
VAR currentGroup = 'Matrix Sort'[Groups]
RETURN CALCULATE(SUM('Matrix Sort'[Sales]), FILTER('Matrix Sort', 'Matrix Sort'[Groups] = currentGroup))
Visual Groups = 'Matrix Sort'[Groups]
Voila! It's done. Let me know if you face any issues!
Proud to be a Super User! Regards, Bipin Lala | Business Intelligence Developer | |
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.