Forum Discussion
Ranking based line chart
Hi all,
Actually I am trying to create a line chart by using ranking.
Sample scenerio:
If I have company A with many products and other companies(like B,C, D considered as others).I have ranked based on sales for 'A' and others individually and took Top 1 rank of 'A' company and top 1 rank of others same way based on that I have considered top 5 ranks of 'A' and top 5 ranks of others individually. Now I want to combine all these to get a line chart that displays top 5 products of company 'A' based on ranks considered and top 5 products of others as a line chart. Any suggestion would be truly be appreciated and helpful.
Thanks in advance.
- Anonymous3 years ago
Hi kompalli ,
Please refer to my pbix file to see if it helps you.
Create a column.
Column = var _1= RANKX(FILTER(ALL('Table'),'Table'[A and others]=EARLIER('Table'[A and others])),'Table'[Sales],,DESC,Dense) return IF(_1<=5,_1,BLANK())Then filter the line chart: Column is not blank.
If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output with more details.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Thanks for your response. Below are the measures for your reference that I have used to rank company "A" and "others" based on product, company and sales measures. It was working fine but when used as measure, the same logic I couldn't apply it to a calculated column.
Rank by A Sales = if (SELECTEDVALUE (Table name [Company]) ="A”, RANKX (
SUMMARIZE (ALL (Table name), Table name [Product], Table name [Company]), [Sales measure], CALCULATE ([Sales measure], Table name [company] = "A"), DESC, Dense))
Rank by others Sales = if (SELECTEDVALUE (Table name [Company]) ="others”, RANKX (SUMMARIZE (ALL (Table name), Table name [Product], Table name [company), [Sales measure], CALCULATE ([Sales measure], Table name [company] = "others"), DESC, Dense))
These are the measures used to rank based on company “A” and “others” but based on these conditions a calculated column is required. I tried doing it but I couldn't get the desired ranking.
- Below image is that shows the expected output in detail.
- There might be similar products repeating for a company over a period based on sales.
- Below is the sample data for your reference.
Company Product Date Sales A and others A A01 01-Feb-20 50 A A A02 01-Feb-20 36 A A A03 01-Feb-20 43 A A A04 01-Feb-20 31 A B B01 01-Feb-20 16 others B B02 01-Feb-20 49 others B B03 01-Feb-20 27 others B B04 01-Feb-20 42 others C C01 01-Feb-20 56 others C C02 01-Feb-20 11 others C C03 01-Feb-20 13 others C C04 01-Feb-20 30 others A A01 01-Mar-20 31 A A A02 01-Mar-20 23 A A A03 01-Mar-20 44 A A A04 01-Mar-20 29 A B B01 01-Mar-20 24 others B B02 01-Mar-20 11 others B B03 01-Mar-20 11 others B B04 01-Mar-20 24 others C C01 01-Mar-20 15 others C C02 01-Mar-20 53 others C C03 01-Mar-20 58 others C C04 01-Mar-20 18 others A A01 01-Apr-20 47 A A A02 01-Apr-20 27 A A A03 01-Apr-20 27 A A A04 01-Apr-20 44 A B B01 01-Apr-20 49 others B B02 01-Apr-20 37 others B B03 01-Apr-20 25 others B B04 01-Apr-20 27 others C C01 01-Apr-20 30 others C C02 01-Apr-20 33 others C C03 01-Apr-20 28 others C C04 01-Apr-20 19 others A A01 01-May-20 34 A A A02 01-May-20 52 A A A03 01-May-20 50 A A A04 01-May-20 27 A B B01 01-May-20 55 others B B02 01-May-20 39 others B B03 01-May-20 15 others B B04 01-May-20 26 others C C01 01-May-20 52 others C C02 01-May-20 13 others C C03 01-May-20 14 others C C04 01-May-20 35 others
- Anonymous3 years ago
Hi kompalli ,
I have created a simple smaple, please refer to it to see if it helps you.
ColumnA = VAR _1= RANKX(FILTER('Table','Table'[company]="A"&&'Table'[DATE]=EARLIER('Table'[DATE])),'Table'[sales],,DESC,Dense) RETURN IF(_1<=5&&'Table'[company]="A",_1,BLANK())ColumnNOA = VAR _1= RANKX(FILTER('Table','Table'[company]<>"A"&&'Table'[DATE]=EARLIER('Table'[DATE])),'Table'[sales],,DESC,Dense) RETURN IF(_1<=5&&'Table'[company]<>"A",_1,BLANK())If it still does not help you, please peovide more details to explain: Company A, date 2020/2/1, the A02 's rankx is 2. There are 50(A01) ,43( A03) ,48(A06) ,40(A07) bigger than it.
It seems other company rankx by date. Why 42(B04) is 1?
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
10 Replies
- AnonymousNot applicable
Hi kompalli ,
I have created a simple sample, please reer to it to see if ithelps you.
Create a column.
RANKX = VAR _1= RANKX(FILTER('Table','Table'[company ]=EARLIER('Table'[company ])),'Table'[sales],,DESC,Skip) RETURN IF(_1<=5,_1,BLANK())If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output with more details.
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- kompalliHelper I
Hi Anonymous ,
Thankyou for responding with a sample file. I tried to share the .pbix file for clear understanding of requirement but I am unable to share it.
- AnonymousNot applicable
Hi kompalli ,
Please refer to .
How to provide sample data in the Power BI Forum - Microsoft Power BI Community
How to Get Your Question Answered Quickly
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- daXtremeSolution Sage
The description is not clear at all. Please read this first: How to Get Your Question Answered Quickly - Microsoft Power BI Community