Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi All,
I have below data in my table and i need to rank the sales on the basis of country, area.brand and product, PFB the sample data:
Country | area | product | Brands | sales | rank |
UK | area1 | xyz | a1 | 500.0 | 7/7 |
UK | area1 | xyz | a2 | 200.0 | 2/7 |
UK | area1 | xyz | a3 | 399.0 | 6/7 |
UK | area1 | xyz | a4 | 233.0 | 3/7 |
UK | area1 | xyz | a5 | 134.0 | 1/7 |
UK | area1 | xyz | a6 | 284.0 | 4/7 |
UK | area1 | xyz | a7 | 374.0 | 5/7 |
US | area1 | xyz | a8 | 279.0 | 2/7 |
US | area1 | xyz | a9 | 376.0 | 5/7 |
US | area1 | xyz | a10 | 373.0 | 4/7 |
US | area1 | xyz | a11 | 253.0 | 1/7 |
US | area1 | xyz | a12 | 379.0 | 6/7 |
US | area1 | xyz | a13 | 743.0 | 7/7 |
US | area1 | xyz | a14 | 333.0 | 3/7 |
i have seven different brands which is selling same product in same area in same country, i need to get the above mentioned rank, for an example: Brand a1 to a7 is selling their product in UK in same area and its sales is captured now i need to find the rank of the brand as per their sales amount.
I have multiple countries data in same table with same format as shown in above sample.
I really appreciate your help on this, thank you in advance.
Please let me know if you need more details on above scenario.
Solved! Go to Solution.
Hi @chayanupadhyay ,
You can try this calculated column.
Column = RANKX ( 'Table', RIGHT ( 'Table'[Period], 4 ) & LEFT ( 'Table'[Period], 2 ), , DESC, DENSE )
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @chayanupadhyay ,
You need to add a new calculated column.
Column = VAR A = RANKX ( CALCULATETABLE ( test, ALLEXCEPT ( test, test[Country], test[area], test[product] ) ), test[sales], , ASC, DENSE ) VAR B = COUNTROWS ( CALCULATETABLE ( test, ALLEXCEPT ( test, test[Country], test[area], test[product] ) ) ) RETURN A & "/" & B
Here is the result.
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @v-eachen-msft for your help. It worked .
I have to rank Quarter and year as well, PFB the sample data:
country | Product | Sales | Period | Rank |
x | a | 200 | Q3 2019 | 1 |
x | b | 300 | Q4 2018 | 2 |
y | b | 200 | Q4 2018 | 2 |
z | b | 200 | Q4 2018 | 2 |
z | a | 239 | Q3 2018 | 3 |
f | a | 134 | Q3 2018 | 3 |
g | b | 143 | Q1 2018 | 4 |
h | c | 234 | Q1 2018 | 4 |
If you could help me on the DAX statement to get the ranking of Period column, since Q3 2019 is the latest which will rank as 1 and then following quarter with the year will be ranked, if the quarter and year are same then same rank needs to be applied.
Period column is text column, Period is coming from source as column and i am unpivoting it and making it as Rows but unable to change its data type to Date and sort it according to that.
Thank you in advance for your help.
Regards,
Chayan Upadhyay
Hi @chayanupadhyay ,
You can try this calculated column.
Column = RANKX ( 'Table', RIGHT ( 'Table'[Period], 4 ) & LEFT ( 'Table'[Period], 2 ), , DESC, DENSE )
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-eachen-msftThank you so much for your help and support.
Apologies for replying late.
It helped me alot 🙂
Thank you @amitchandak for sharing the link.
In that use case, they have ranked total sales amount for each combination, in my case i need to rank each brand on their individual sales amount comparing to the other brand sales amount for same country, same area and same product.
Please check these formulae. These have been created as measures, not columns. If one create them as column they will become aggregatable. There is diff, how you calculate these two
RANK Test = VAR x = SUM(Sales[Sales]) RETURN RANKX( ALL(Customer[Age Group]), CALCULATE(SUM(Sales[Sales]) )) RANK Test 1 = VAR x = SUM(Sales[Sales]) RETURN RANKX( ALL(Customer[Income Group]), CALCULATE(SUM(Sales[Sales]) )) RANK Test 2 = VAR x = SUM(Sales[Sales]) RETURN RANKX( ALL(Customer[Age Group],Customer[Income Group]), CALCULATE(SUM(Sales[Sales]) ))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
83 | |
75 | |
64 | |
39 | |
34 |
User | Count |
---|---|
107 | |
56 | |
52 | |
48 | |
40 |