Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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 |
---|---|
143 | |
71 | |
69 | |
53 | |
52 |
User | Count |
---|---|
208 | |
94 | |
64 | |
60 | |
57 |