Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Dynamic Rank Order

I'm working with a dataset of 4.5 million entries, spanning 3 years and multiple other criteria that I'd like to slice the data on.  Where I'm struggling is trying to get the financial values to re-rank based off the criteria selected.

 

I have the following fields in my data, all in one table:

PID: unique identifier for each person, may be duplicated across years but not within a single year

OM: sum of the financial value for each person in a given year

Year: the three years (2018-2020) in my dataset

Age: Person's age

Gender: Person's gender

Category: A buyer classification

 

Example (dummy) data:

 

At a bare minimum, I'd like to rank order OM and be able to see all three years or filter to a single year. 

Example: Ordering within year 2018

Ranking across the whole dataset:

Ideally, I'd like to apply other filters, such as Category. 

 

Do I need to create a new measure or column for every subset I want to explore?  Can I create one dynamic function that will recalculate when different filters are applied?

 

Thanks,

Michael

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    What is your corresponding expected result? Please give the expected results in tabular form.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I've updated the original post with more information on intended results.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Try this measure

    Rank = RANKX(ALLSELECTED('Table'),CALCULATE(SUM('Table'[OM])),,DESC,Dense)

     

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Stephen,

      Thank you for your help with this.  I tested your solution and it works on the test data.  Unfortunately, when I apply it to the full dataset, I'm getting strange results (see below).

       

      This is on the unfiltered data (so, all years 2018-2020).  As you can see, there's a tied rank for #7 and #19, even though the OM values are different.  The rank ordering also skips #13 for no apparent reason.

      Do you have any ideas as to what is causing this?