Forum Discussion

kompalli's avatar
kompalli
Helper I
3 years ago
Solved

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.

  • Anonymous's avatar
    Anonymous
    3 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.

     

  • kompalli's avatar
    kompalli
    3 years ago

    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.
    • CompanyProductDateSalesA and others
      AA0101-Feb-2050A
      AA0201-Feb-2036A
      AA0301-Feb-2043A
      AA0401-Feb-2031A
      BB0101-Feb-2016others
      BB0201-Feb-2049others
      BB0301-Feb-2027others
      BB0401-Feb-2042others
      CC0101-Feb-2056others
      CC0201-Feb-2011others
      CC0301-Feb-2013others
      CC0401-Feb-2030others
      AA0101-Mar-2031A
      AA0201-Mar-2023A
      AA0301-Mar-2044A
      AA0401-Mar-2029A
      BB0101-Mar-2024others
      BB0201-Mar-2011others
      BB0301-Mar-2011others
      BB0401-Mar-2024others
      CC0101-Mar-2015others
      CC0201-Mar-2053others
      CC0301-Mar-2058others
      CC0401-Mar-2018others
      AA0101-Apr-2047A
      AA0201-Apr-2027A
      AA0301-Apr-2027A
      AA0401-Apr-2044A
      BB0101-Apr-2049others
      BB0201-Apr-2037others
      BB0301-Apr-2025others
      BB0401-Apr-2027others
      CC0101-Apr-2030others
      CC0201-Apr-2033others
      CC0301-Apr-2028others
      CC0401-Apr-2019others
      AA0101-May-2034A
      AA0201-May-2052A
      AA0301-May-2050A
      AA0401-May-2027A
      BB0101-May-2055others
      BB0201-May-2039others
      BB0301-May-2015others
      BB0401-May-2026others
      CC0101-May-2052others
      CC0201-May-2013others
      CC0301-May-2014others
      CC0401-May-2035

      others

  • Anonymous's avatar
    Anonymous
    3 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