Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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] )
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] )
This works perfectly, thank you!
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 50 | |
| 44 | |
| 42 | |
| 19 | |
| 19 |
| User | Count |
|---|---|
| 69 | |
| 68 | |
| 33 | |
| 32 | |
| 32 |