+ Reply to Thread
Results 1 to 41 of 41

Rankif with 2 criteria

  1. #1
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Rankif with 2 criteria

    Hi guys,

    I need to rank using 2 criteria (the people and the group of products) based on the cost. I attached the excel file for easy understanding.

    Thanks!

    Updated file - 4/9/14
    Attached Files Attached Files
    Last edited by huy_le; 04-09-2014 at 11:41 AM.

  2. #2
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Also, there will be errors in the product column. The ranking should ignore these.

  3. #3
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,367

    Re: Rankif with 2 criteria

    =(SUMPRODUCT(($A$2:$A$13=A2)*($B$2:$B$13=B2)*($C$2:$C$13>C2))+1)+COUNTIFS($C$2:C2,C2,$B$2:$B2,B2,$C$2:C2,C2,$A$2:$A2,A2)-1

    Put In D2 and copied down.....

  4. #4
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi Azumi,

    Your formula does not work, it's not grouping the products.

  5. #5
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,367

    Re: Rankif with 2 criteria

    Yes your data has several #N/A, try to remove them, the formula cant calculate rank your data....

  6. #6
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi Azumi,

    That's part of the worksheet because it's part of the lookup and some do not have data. That is why I want to ignore the errors if it is possible with formula.

  7. #7
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,367

    Re: Rankif with 2 criteria

    in my knowledge its impossible to ignore it, sorry

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Rankif with 2 criteria

    Quote Originally Posted by huy_le View Post
    Hi Azumi,

    That's part of the worksheet because it's part of the lookup and some do not have data. That is why I want to ignore the errors if it is possible with formula.
    Include error trapping in your lookup to remove the error
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi FDibbins,

    I can use "" to remove the errors, and I used Azumi's formula but it does not group the product. For example, for A, bottle should be 3, but it shows as 1.

  10. #10
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi,

    Does anyone have answer? I would much appreciate.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Can you update your sample file to show us what results you expect?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  12. #12
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi Tony,

    I have updated the file to reflect what I want.

    Best,
    Huy

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Data Range
    A
    B
    C
    D
    E
    1
    People
    Product
    Cost
    What I want
    2
    A
    Glass
    500
    2
    3
    A
    Bottle
    700
    3
    4
    A
    Glass
    200
    2
    5
    A
    Cup
    900
    1
    6
    A
    None
    7
    B
    Cup
    100
    2
    8
    B
    Glass
    400
    3
    9
    B
    Cup
    500
    2
    10
    B
    Bottle
    700
    1
    11
    B
    None
    12
    C
    Bottle
    800
    1
    13
    C
    Cup
    300
    2
    14
    C
    Glass
    200
    3
    15
    C
    Bottle
    300
    1
    16
    C
    None
    17
    ------
    ------
    ------
    ------
    ------




    Can you explain the logic needed to arrive at those results?

  14. #14
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    So I want to rank the product based on cost for each person. Say, for A, Cup should be 1, Glass "group" should be 2, and Bottle should be 3. Does it make sense?

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Do you mean like this...

    A - Cup - total = 900 = 1
    A - Glass - total = 700 = 2
    A - Bottle - total = 700 = 3

  16. #16
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Yes! That is exactly what I want.

  17. #17
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi guys, any luck on this?

  18. #18
    Valued Forum Contributor
    Join Date
    03-20-2011
    Location
    UK
    MS-Off Ver
    Excel 2007/10/16
    Posts
    840

    Re: Rankif with 2 criteria

    Hi.

    Please click on Attachment. Information are in there.

    regard
    micope21
    To help you by my post? it would be nice to click on to say "Thank you".
    If you are happy with a solution to your problem?
    Click Thread Tools above your first post,
    select "Mark your thread as Solved".

  19. #19
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Are you able to change the data structure to something like this:

    Data Range
    G
    H
    I
    J
    1
    People
    Product
    Cost
    Rank
    2
    A
    Glass
    700
    2
    3
    A
    Bottle
    700
    3
    4
    A
    Cup
    900
    1
    5
    B
    Glass
    400
    3
    6
    B
    Bottle
    700
    1
    7
    B
    Cup
    600
    2
    8
    C
    Glass
    200
    3
    9
    C
    Bottle
    1100
    1
    10
    C
    Cup
    300
    2
    Last edited by Tony Valko; 04-14-2014 at 01:10 PM.

  20. #20
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi Tony,

    I am not able to, my data is very large to do this.

  21. #21
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi micope21,

    Thank you for helping me. However, this is not what I am looking for.
    Quote Originally Posted by micope21 View Post
    Hi.

    Please click on Attachment. Information are in there.

    regard
    micope21

  22. #22
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Well, nothing I've tried works.

    You've stumped me!

  23. #23
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Rankif with 2 criteria

    Almost...but stumped on tie totals,

    Please Login or Register  to view this content.
    Or,

    Please Login or Register  to view this content.
    Last edited by Haseeb Avarakkan; 04-11-2014 at 10:04 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  24. #24
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    I guess this request is too difficult (

  25. #25
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    No doubt it's complicated but I'm sure someone can do this.

    The right person just hasn't seen this thread. Let me put a link to it in the "Call in the Cavalry" thread.

  26. #26
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Rankif with 2 criteria

    Can someone explain the logic to me? Baffled.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  27. #27
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    Data Range
    A
    B
    C
    D
    E
    1
    People
    Product
    Cost
    What I want
    2
    A
    Glass
    500
    2
    3
    A
    Bottle
    700
    3
    4
    A
    Glass
    200
    2
    5
    A
    Cup
    900
    1
    6
    A
    None
    7
    B
    Cup
    100
    2
    8
    B
    Glass
    400
    3
    9
    B
    Cup
    500
    2
    10
    B
    Bottle
    700
    1
    11
    B
    None
    12
    C
    Bottle
    800
    1
    13
    C
    Cup
    300
    2
    14
    C
    Glass
    200
    3
    15
    C
    Bottle
    300
    1
    16
    C
    None
    17
    ------
    ------
    ------
    ------
    ------


    E2 = the rank of SUMIFS(C:C,A:A,A2,B:B,B2) if column A = A2
    E3 = the rank of SUMIFS(C:C,A:A,A3,B:B,B3) if column A = A3
    E4 = the rank of SUMIFS(C:C,A:A,A4,B:B,B4) if column A = A4
    etc
    etc
    etc

  28. #28
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Rankif with 2 criteria

    Thanks, Tony, that's great.

    Not sure I understand why E2, E3 and E4 aren't all 2, but perhaps this in E2 and copied down:

    =IF(B2="","None",1+SUMPRODUCT(0+(SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B$2:B$200)>SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B2)))/COUNTIFS(B$2:B$200,B2))

    Amend the 200 to a suitably higher value if required.

    Regards

  29. #29
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Rankif with 2 criteria

    Hi. Maybe this formula can help? Paste to E2 cel and then Ctrl+Shift+Enter
    Please Login or Register  to view this content.
    Only for Group A - Bottle rank will give you incorrect answer. I think with helper columns solution is possible.
    Appreciate the help? CLICK *

  30. #30
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Rankif with 2 criteria

    I used helper table.
    =IFERROR(INDEX(RANK(INDEX($I$2:$L$10,0,MATCH(A2,$I$1:$L$1,0)),INDEX($I$2:$L$10,0,MATCH(A2,$I$1:$L$1,0))),MATCH(B2,$H$2:$H$10,0)),"")

    For more information see the attached file.

    In previous formula (of mine) E2, e3 e4 was giving same answer because their results were same (700).
    Attached Files Attached Files

  31. #31
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Rankif with 2 criteria

    Can someone check this:
    (one helper column)
    Attached Files Attached Files

  32. #32
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    @ XOR...

    For group A I think the desired results are: 2, 3, 2, 1.

    Your formula returns: 2, 2, 2, 1.

    It looks like they want a tie breaker similar to:

    Data Range
    A
    B
    C
    D
    1
    Group
    Item
    Value
    Rank
    2
    A
    X
    10
    1
    3
    A
    X
    10
    1
    4
    A
    Y
    10
    2
    5
    A
    Z
    8
    3
    6
    A
    Z
    8
    3
    Last edited by Tony Valko; 04-14-2014 at 06:29 PM.

  33. #33
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Rankif with 2 criteria

    I think the goal here is to not have to use helper columns.

  34. #34
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Hi guys,

    Thanks a lot for helping me with this. The goal of course is not to use the use helper columns, but if it's too difficult I am fine with that.

    Also, for the tie breaker, I actually want the same ranking for Glass and Bottle for A since they both have cost of 700. I was not clear when making the thread. Greatly apologize.

  35. #35
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Rankif with 2 criteria

    So did my solution not give you that?

    Regards

  36. #36
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    I overlooked this, this one works!!! Thanks!

    Quote Originally Posted by XOR LX View Post
    Thanks, Tony, that's great.

    Not sure I understand why E2, E3 and E4 aren't all 2, but perhaps this in E2 and copied down:

    =IF(B2="","None",1+SUMPRODUCT(0+(SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B$2:B$200)>SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B2)))/COUNTIFS(B$2:B$200,B2))

    Amend the 200 to a suitably higher value if required.

    Regards

  37. #37
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Rankif with 2 criteria

    Thanks all for your tireless help over the last few days. I fail to describe how much I appreciate it.

  38. #38
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Rankif with 2 criteria

    You're welcome!

  39. #39
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Rankif with 2 criteria

    Quote Originally Posted by XOR LX View Post
    =IF(B2="","None",1+SUMPRODUCT(0+(SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B$2:B$200)>SUMIFS(C$2:C$200,A$2:A$200,A2,B$2:B$200,B2)))/COUNTIFS(B$2:B$200,B2))
    Doesn't this work here simply because Cup, Bottle and Glass all occur an equal number of times? What results do you get if you change B2 to Cup?
    Audere est facere

  40. #40
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Rankif with 2 criteria

    Quote Originally Posted by daddylonglegs View Post
    Doesn't this work here simply because Cup, Bottle and Glass all occur an equal number of times? What results do you get if you change B2 to Cup?
    Good point.

    Apologies to all interested parties, especially the OP, for the lack of rigour.

    Back to the drawing board. May be a simple fix, though I'm not initially hopeful.

    Regards

  41. #41
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Rankif with 2 criteria

    Given that ties should be ranked the same Haseeb's suggestion works for me

    Quote Originally Posted by Haseeb A View Post
    =IF(B2="","None",SUM(IF(SUMIFS(C$2:C$16,B$2:B$16,B2,A$2:A$16,A2)<SUMIFS(C$2:C$16,A$2:A$16,A2,B$2:B$16,LOOKUP(IF(MATCH(A2&"_"&B$2:B$16,A$2:A$16&"_"&B$2:B$16,0)=ROW(A$2:A$16)-ROW(A$2)+1,ROW(A$2:A$16)),ROW(A$2:A$16),B$2:B$16)),1))+1)
    .......although I think you can eliminate the LOOKUP and use this slightly shorter version

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Either way, needs to be confirmed with CTRL+SHIFT+ENTER

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Rankif Question
    By huy_le in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-18-2014, 07:23 PM
  2. [SOLVED] Count of rows in an array that meet criteria in column 2 and different criteria in column3
    By reynoldslarry in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-09-2013, 01:51 AM
  3. Replies: 4
    Last Post: 01-08-2013, 12:37 PM
  4. Rankif?
    By Lee Harris in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-20-2007, 05:28 AM
  5. Is there a rankif function
    By Dan in forum Excel General
    Replies: 3
    Last Post: 05-27-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1