Forum Discussion

RX229's avatar
RX229
Frequent Visitor
3 years ago

Ranking by two criteria.

Hello,

How to figure out ranking of vendors by max count of widgets produced while taking minimum number of days? 

 

Thanks

 

Vendor

Count

Total Days

A

101

24,613

B

79

24,607

C

35

8,699

D

20

5,206

E

15

6,952

F

21

3,044

G

12

866

2 Replies

  • HI RX229 

     

    In Power BI, you can use the DAX formula RANKX to determine the ranking of vendors based on the maximum count of widgets produced while taking the minimum number of days. Here is an example of how you can do this:

    Create a new measure that calculates the maximum count of widgets produced by each vendor, using the MAX function:
    Copy code
    Max Widgets = MAX(VendorData[Count])
    Create a new measure that calculates the minimum number of days for each vendor, using the MIN function:
    Copy code
    Min Days = MIN(VendorData[Total Days])
    Use the RANKX function to rank the vendors based on a combination of the Max Widgets and Min Days measures, giving priority to the maximum count of widgets produced:
    Copy code
    Ranking = RANKX(ALL(VendorData), CALCULATE(SUM(VendorData[Max Widgets]) + SUM(VendorData[Min Days])), , DESC, Dense)
    This will give you a ranking of vendors based on the maximum count of widgets produced, with ties broken by the minimum number of days. The ranking will be based on the values of the new measure Ranking.

    You can also use the RANKX function to sort the vendors by the maximum count of widgets produced and the minimum number of days in ascending or descending order, by changing the , DESC, Dense to ,ASC,Dense

    You can adjust codes according to your data and the way you want to prioritize the ranking.

     

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

    Appreciate your Kudos!! 

    LinkedIn | Twitter | Blog | YouTube