Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi community,
I have a table like the below, with cutstomers and sales quantity. Im looking to rank these customers based on the postcode area they sit within.
Any ideas how i can do this within a Dax formula ? Many thanks !
| Customer | Postcode | Sales Quantity | Rank |
| A | DY | 1000 | 2 |
| B | DY | 1200 | 1 |
| C | B | 1500 | 1 |
| E | B | 1250 | 2 |
| F | WR | 1000 | 1 |
| G | WR | 950 | 2 |
Solved! Go to Solution.
Hi @Caldowd98
If you have multiple lines per customer, you can try this,
create the measure below,
RANK =
RANKX (
FILTER ( ALL ( 'Table' ), 'Table'[Postcode] = MIN ( 'Table'[Postcode] ) ),
CALCULATE (
SUM ( 'Table'[Sales Quantity] ),
ALLEXCEPT ( 'Table', 'Table'[Customer], 'Table'[Postcode] )
),
,
DESC,
DENSE
)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
You could add a calculated column like
Ranking =
var currentPostcode = 'Table'[Postcode]
var currentAmount = 'Table'[Sales]
return RANKX( FILTER( 'Table', 'Table'[Postcode] = currentPostcode), 'Table'[Sales], currentAmount)
Hi great, thank you for help !
I have however multiple lines per customer, how would i group these and sum the QTY ?
Many thanks
Hi @Caldowd98
If you have multiple lines per customer, you can try this,
create the measure below,
RANK =
RANKX (
FILTER ( ALL ( 'Table' ), 'Table'[Postcode] = MIN ( 'Table'[Postcode] ) ),
CALCULATE (
SUM ( 'Table'[Sales Quantity] ),
ALLEXCEPT ( 'Table', 'Table'[Customer], 'Table'[Postcode] )
),
,
DESC,
DENSE
)
result
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |