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! It's time to submit your entry. Live now!
Hi
I have DAX string here where I want to simply rank customers by sales and have ranking #.
Solved! Go to Solution.
Thanks for the reply from @rajendraongole1 , please allow me to provide another insight:
Hi @Matt78 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
True_Measure =
var _table1=
SUMMARIZE(
ALL('CustomerTable'),[Customer],"Total Sales Measure",[Total Sales])
var _table2=
ADDCOLUMNS(
_table1,"Rank",RANKX(_table1,[Total Sales Measure],,DESC))
return
MAXX(
FILTER(_table2,[Customer]=MAX('CustomerTable'[Customer])),[Rank])
2. Result:
Before filtering:
After filtering:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Matt78 ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the reply from @rajendraongole1 , please allow me to provide another insight:
Hi @Matt78 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
True_Measure =
var _table1=
SUMMARIZE(
ALL('CustomerTable'),[Customer],"Total Sales Measure",[Total Sales])
var _table2=
ADDCOLUMNS(
_table1,"Rank",RANKX(_table1,[Total Sales Measure],,DESC))
return
MAXX(
FILTER(_table2,[Customer]=MAX('CustomerTable'[Customer])),[Rank])
2. Result:
Before filtering:
After filtering:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi
With this I get the following result:
br
Matt
Hi @Matt78 - I have done slight modification to your measure can you try the below measure, allselected ensures ranking considers the current filters except for the context of the current row.
RANK = RANKX(
ALLSELECTED('CustomerTable'[BUSINESS_UNIT_NAME_FI]),
[Total Sales],
,
DESC,
DENSE
)
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Hi,
When I have all customers listed it ranks ok but still if I filter to only one customer, it gives #1 rank to every customer
br
Matt
Hi @Matt78 - Can you try the below refined measure
Customer Rank =
IF(
ISFILTERED('Customers'[CustomerID]),
RANKX(
ALL('Customers'[CustomerID]),
CALCULATE(SUM('Sales'[Amount]))
),
RANKX(
ALLSELECTED('Customers'[CustomerID]),
CALCULATE(SUM('Sales'[Amount]))
)
)
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 50 | |
| 43 | |
| 36 | |
| 33 | |
| 30 |
| User | Count |
|---|---|
| 138 | |
| 126 | |
| 60 | |
| 59 | |
| 56 |