Hopeless Cub Fan
New Member
- Joined
- May 25, 2011
- Messages
- 31
I am looking to create a DAX formula to rank just the top x% of sales $’s in a pivot table. The goal is to be able to filter out the records that do not hit the top x% threshold and then sort the remaining records based on their rank. I will be using this functionality to create a “Top Movers” (both positive and negative) report.
Below is a sample data set that illustrates how I am currently doing this ranking outside of the pivot.
Excel 2010
<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
<tbody>
</tbody>
Additional Notes:
Thanks in advance for any help you can offer!
Below is a sample data set that illustrates how I am currently doing this ranking outside of the pivot.
Excel 2010
A | B | C | D | E | F | G | H | I | J | |
---|---|---|---|---|---|---|---|---|---|---|
1 | Group | Sub Group | Current Month 2015 Sales | Current Month 2014 Sales | Current Month YOY Sales Var | Current Month YOY Sales Var % | YOY Sales Growth Rank | % of Running Total | Top 80%? | Growth % Rank (Top 80% of PY Sales) |
2 | A | 1 | 500 | 350 | 150 | 43% | 6 | 29.0% | x | 3 |
3 | A | 5 | 325 | 325 | - | 0% | 9 | 55.9% | x | 4 |
4 | A | 4 | 250 | 145 | 105 | 72% | 4 | 67.9% | x | 1 |
5 | A | 6 | 225 | 140 | 85 | 61% | 5 | 79.5% | x | 2 |
6 | A | 9 | 125 | 100 | 25 | 25% | 7 | 87.8% | ||
7 | A | 8 | 450 | 75 | 375 | 500% | 2 | 94.0% | ||
8 | A | 3 | 50 | 45 | 5 | 11% | 8 | 97.8% | ||
9 | A | 2 | 100 | 25 | 75 | 300% | 3 | 99.8% | ||
10 | A | 7 | 50 | 2 | 48 | 2400% | 1 | 100.0% | ||
11 | Total | 2,075 | 1,207 | 868 | 72% |
<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
Worksheet Formulas
<thead> </thead><tbody> </tbody> |
<tbody>
</tbody>
Additional Notes:
- Ranking will be done off "Current Month YOY Sales Var %"
- Goal is to rank only the top X% of customers (in this example 80%) based off prior year sales. The last record in the example above shows ridiculious growth, but that is due to the low baseline (2).
- I have a DAX rank formula (below) that properly ranks fields, but has the following problems:
- RANKX(FILTER(All(Table1[CRPCUSNM]),Table1[Current Month YOY Sales Var]),Table1[Current Month YOY Sales Var],,,Dense)
- Ranks all "CRPCUSNM" values, not just the top 50% of sales. I've tried to restrict it, but can't get it to work.
- Rank only works when "CRPCUSNM" is in the report. I would like to have a dynamic rank that adjusts based on the level of granularity in the pivot report without the need to reference a specific field.
Thanks in advance for any help you can offer!