+ Reply to Thread
Results 1 to 8 of 8

Ranking with RANK and SUMPRODUCT based on Two Value Columns

  1. #1
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Ranking with RANK and SUMPRODUCT based on Two Value Columns

    I am trying to rank based on two value columns - (Aggregate and Raw Score) - such that it should rank by Aggregate (Column B), then by Raw Score (Column C).
    In the data, the least Aggregate should be ranked first and highest aggregate should be last.

    However, where two or more persons have same Aggregate, then the highest Raw Score should be used to separate them.
    I used the formula below:

    =RANK(C2,$C$2:$C$130)+SUMPRODUCT(--($C$2:$C$130=$C2),--(B2>$B$2:$B$130))&MID("thstndrdth",MIN(9,2*RIGHT(RANK(C2,$C$2:$C$130))*(MOD(RANK(C2,$C$2:$C$130)-11,200)>2)+1),2)

    but, it seems some persons with higher Aggregates with higher Raw Score have been ranked before those with least Aggregate.

    Any help to rank them by least Aggregate then by highest Raw Score.

    Data attached
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Please try
    F2
    =SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1

  3. #3
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Thanks a lot.
    The ranking is done with a perfect separation of tie aggregates
    But the "st th nd rd" suffixes are messed up.
    I think the problem is with second part of the function:

    &MID("thstndrdth",MIN(9,2*RIGHT(RANK(C2,$C$2:$C$130))*(MOD(RANK(C2,$C$2:$C$130)-11,200)>2)+1),2)

    Can you please help?

    Thanks in advance

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Just replace RANK(C2,$C$2:$C$130) with SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1

    =SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1&MID("thstndrdth",MIN(9,2*RIGHT(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1)*(MOD(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1-11,200)>2)+1),2)

  5. #5
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Thanks in a million, BO_RY

    It works perfectly EXCEPT for 111, 112 and 113 positions, which pick 111st, 112nd and 113rd instead of 111th, 112th and 113th

    I have no idea on how to solve this.

    Any solution, please!

    Thanks
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Change:

    =SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1&MID("thstndrdth",MIN(9,2*RIGHT(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1)*(MOD(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1-11,200)>2)+1),2)

    to:

    =SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1&MID("thstndrdth",MIN(9,2*RIGHT(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1)*(MOD(SUMPRODUCT(--(GRADE*1000-RSCORE<B2*1000-C2))+1-11,100)>2)+1),2)

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Try this.
    In Row2 then drag down.

    =SUMPRODUCT(--(($B$2:$B$130-($C$2:$C$130*10^-8))<($B2-$C2*10^-8)))+1
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  8. #8
    Registered User
    Join Date
    05-07-2014
    Location
    Ghana
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Ranking with RANK and SUMPRODUCT based on Two Value Columns

    Thanks so so much, Bo_Ry, Phuocam and kvsrinivasamurthy, for your prompt, perfect and life-saving solutions.
    In fact, you guys are geniuses.

    It works perfectly as I really wanted.

    Many thanks.

+ 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. Replies: 4
    Last Post: 07-13-2017, 05:45 PM
  2. Replies: 3
    Last Post: 02-08-2016, 06:55 PM
  3. How to Rank & Sort based on ranking using VB Code?
    By ray.kanata in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2015, 10:58 AM
  4. Trying to create ranking list with swapping rows based on rank
    By OAHMC in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-03-2015, 08:37 PM
  5. Ranking values and ranking duplicates the same rank
    By 302arpks in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 03-05-2015, 01:50 PM
  6. Replies: 5
    Last Post: 07-24-2012, 01:03 PM
  7. Replies: 6
    Last Post: 06-01-2010, 06:19 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