Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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! | |
User | Count |
---|---|
117 | |
75 | |
62 | |
50 | |
44 |
User | Count |
---|---|
174 | |
125 | |
60 | |
60 | |
57 |