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.
Hello,
I am trying to rank a list of stores by sales on a period by period basis. For example, this is what a desired table would look like:
Period | Store | Sales | Rank |
1 | A | 100 | 2 |
1 | B | 150 | 1 |
1 | C | 75 | 3 |
2 | A | 110 | 3 |
2 | B | 120 | 2 |
2 | C | 135 | 1 |
Then I would like have the sum of the ranks for each store like so:
Store | Sum of Rank |
A | 5 |
B | 3 |
C | 4 |
I am able to calculate the ranks in the first table using the following measure:
Rank =
RANKX(
FILTER(
ALL(Table[Period], Table[Store])
Table[Period] = MAX(Table[Period])
),
CALCULATE(SUM(Table[Sales])
)
Solved! Go to Solution.
Hi,
I am not sure what is your desired outcome, but I tried to create it by using measures.
Please check the below picture and the attached pbix file.
It is for creating a measure.
Expected result measure: =
VAR _rank =
ADDCOLUMNS (
VALUES ( Period[Period] ),
"@rank",
RANK (
SKIP,
SUMMARIZE ( ALL ( Data ), Store[Store], Period[Period] ),
ORDERBY ( CALCULATE ( SUM ( Data[Sales] ) ), DESC ),
PARTITIONBY ( Period[Period] )
)
)
RETURN
SUMX ( _rank, [@rank] )
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.
Hi,
I am not sure what is your desired outcome, but I tried to create it by using measures.
Please check the below picture and the attached pbix file.
It is for creating a measure.
Expected result measure: =
VAR _rank =
ADDCOLUMNS (
VALUES ( Period[Period] ),
"@rank",
RANK (
SKIP,
SUMMARIZE ( ALL ( Data ), Store[Store], Period[Period] ),
ORDERBY ( CALCULATE ( SUM ( Data[Sales] ) ), DESC ),
PARTITIONBY ( Period[Period] )
)
)
RETURN
SUMX ( _rank, [@rank] )
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.
This works perfectly, thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
96 | |
79 | |
65 | |
62 |
User | Count |
---|---|
147 | |
116 | |
104 | |
88 | |
65 |