Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi Folks!
Considering a mock table like this one:
Option | Option_index | Sub Category | Value |
Blue | 1 | Dark | 22 |
Blue | 1 | Light | 345 |
Red | 2 | Dark | 456 |
Green | 3 | Medium | 654 |
I want to rank the sum of Value by 'Option' :
Sum(Blue)=367, so rank=3
Sum(Red)=456, so rank=2
Sum(Green)=654, so rank=1
The measure is as follow:
MyRank=RANKX(All(Table[Option]),CALCULATE(SUM(value)))
When I put in a matrix visual my 'Option' and 'MyRank', I do get the expected result. But as soon as I want to sort my column 'Option' (in column tools menu, sort column by) by 'Option_index', all MyRank values end up being 1 in my visual.
Do you understand that logic? I don't...
thx in advance for your inputs!
Ben
Solved! Go to Solution.
This behaviour is described in this article:
https://www.sqlbi.com/articles/side-effects-in-dax-of-the-sort-by-column-setting/
In short, sort-by columns are added to a visual's DAX query along with the column being sorted, which means that modifiers such as ALL() should be applied to the sort-by column as well.
Try this:
MyRank=
RANKX (
ALL ( Table[Option], Table[Option_index] ),
CALCULATE( SUM ( value ) )
)
Regards,
Owen
This behaviour is described in this article:
https://www.sqlbi.com/articles/side-effects-in-dax-of-the-sort-by-column-setting/
In short, sort-by columns are added to a visual's DAX query along with the column being sorted, which means that modifiers such as ALL() should be applied to the sort-by column as well.
Try this:
MyRank=
RANKX (
ALL ( Table[Option], Table[Option_index] ),
CALCULATE( SUM ( value ) )
)
Regards,
Owen
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
18 | |
13 | |
12 | |
11 | |
8 |