Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Ranking by three criteria

Hi PBI community,

I'm trying to rank a set of data (contracts), in ASCENDING order, according three criteria (columns):

  1. Year = 2011, 2012, , 2030
  2. Month = 1, 2, , 12 
  3. Priority = 1, 2, 3, , 19
ContractPriorityYearMonth
A120131
B1320203
C1320163
D520225
E19201812
F320203

 

Desired output:

ContractPriorityYearMonthRank
A1201311
B13202035
C13201632
D5202256
E192018123
F3202034

 

Should I use Rankx?

 

Tks in advance!

  • Yes Anonymous , but I would create a helper column. If in Power Query, create a custom column that is this:

    = [Year] * 10000 + [Month] * 10 + [Priority]

    That would create a column with 20200313 for example for 2020, March, priority 13.

    If you create a calculated column, it would be pretty much the exact same formula.

     

    I generally recommend custom columns in Power Query, but here, I don't think it makes a difference.

     

    Then use RANKX() using this column.  

3 Replies

  • edhans's avatar
    edhans
    Icon for Community Champion rankCommunity Champion

    Yes Anonymous , but I would create a helper column. If in Power Query, create a custom column that is this:

    = [Year] * 10000 + [Month] * 10 + [Priority]

    That would create a column with 20200313 for example for 2020, March, priority 13.

    If you create a calculated column, it would be pretty much the exact same formula.

     

    I generally recommend custom columns in Power Query, but here, I don't think it makes a difference.

     

    Then use RANKX() using this column.  

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you very much edhans ! It worked!

      • edhans's avatar
        edhans
        Icon for Community Champion rankCommunity Champion

        Excellent Anonymous. Glad to be of assistance. A little bit of tinkering with the model can sometimes make the DAX so much easier. 😁