Forum Discussion

rbalza's avatar
rbalza
Icon for Helper III rankHelper III
5 years ago
Solved

Group based on TopN

Hi PowerBi Superstars,

 

Would like to know, how will I group this data based on TopN? I have a custom group table and I wanted to use it as a basis of TopN. Having a hard time to pull this off. Sample data is attached. Thanks!


https://www.dropbox.com/s/xszrjtxt9oo8k76/sampledata.pbix?dl=0

 

  • Hi, rbalza 

    I am not quite sure if I understood your question correctly, but please check the below picture and the sample pbix file's link down below.

    All measures (two measures) are in the sample pbix file.

     

    Jihwan Rank by Invoice Type =
    RANKX(ALLSELECTED(FactFinalisedInvoicesDetailed[Invoice Type]),[Total Invoice], , DESC)
     
    Jihwan Invoice Total by Group =
    SUMX (
    KEEPFILTERS (
    FILTER (
    ALLSELECTED ( FactFinalisedInvoicesDetailed[Invoice Type] ),
    COUNTROWS (
    FILTER (
    'Customer Rank',
    [Jihwan Rank by Invoice Type] >= 'Customer Rank'[Min Rank]
    && [Jihwan Rank by Invoice Type] <= 'Customer Rank'[Max Rank]
    )
    ) > 0
    )
    ),
    [Total Invoice]
    )
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

     

     

  • Hi, rbalza 

    Thank you for your feedback.

    If you can see my measure, the ranking is only considering Invoice Type.

    If you change the ranking measure to consider Invoice Type and Group Owner together, it will work.

     

    Thank you.

     

    Hi, My name is Jihwan Kim.

     

    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

     

    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

8 Replies

    • rbalza's avatar
      rbalza
      Icon for Helper III rankHelper III

      amitchandak TopN based on the group below. and It shouldn't be on a slicer. It's like the topn will be above on datas (like a drop down thing)

       

  • Hi, rbalza 

    I am not quite sure if I understood your question correctly, but please check the below picture and the sample pbix file's link down below.

    All measures (two measures) are in the sample pbix file.

     

    Jihwan Rank by Invoice Type =
    RANKX(ALLSELECTED(FactFinalisedInvoicesDetailed[Invoice Type]),[Total Invoice], , DESC)
     
    Jihwan Invoice Total by Group =
    SUMX (
    KEEPFILTERS (
    FILTER (
    ALLSELECTED ( FactFinalisedInvoicesDetailed[Invoice Type] ),
    COUNTROWS (
    FILTER (
    'Customer Rank',
    [Jihwan Rank by Invoice Type] >= 'Customer Rank'[Min Rank]
    && [Jihwan Rank by Invoice Type] <= 'Customer Rank'[Max Rank]
    )
    ) > 0
    )
    ),
    [Total Invoice]
    )
     
     

    Hi, My name is Jihwan Kim.


    If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


    Linkedin: linkedin.com/in/jihwankim1975/

    Twitter: twitter.com/Jihwan_JHKIM

     

     

    • rbalza's avatar
      rbalza
      Icon for Helper III rankHelper III

      Hi Jihwan_Kim , thanks for your time solving this. It is getting there, however,  when I place the group owner, it doesn't display properly the topN anymore.

       

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Icon for Super User rankSuper User

        Hi, rbalza 

        Thank you for your feedback.

        If you can see my measure, the ranking is only considering Invoice Type.

        If you change the ranking measure to consider Invoice Type and Group Owner together, it will work.

         

        Thank you.

         

        Hi, My name is Jihwan Kim.

         

        If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

         

        Linkedin: linkedin.com/in/jihwankim1975/

        Twitter: twitter.com/Jihwan_JHKIM