+ Reply to Thread
Results 1 to 11 of 11

Eliminate Duplicates In Rank Formulas

  1. #1
    Forum Contributor
    Join Date
    04-06-2006
    Posts
    131

    Question Eliminate Duplicates In Rank Formulas

    Hey Everyone,

    I'm in a real conundrum, and I'm really hoping one of the experts here can help me out!!



    In a nut shell, I have a sheet with a whole ton of values, one of which being a category column with 50 different possible values. A formula counts up how many times each of these values occur. From there, I have a Rank formula beside each one; for example =RANK(S3,$S$3:$S$53).

    Here's where the problem is coming in...

    On the main page of my book I have a section to show the top ten categories. What I have it doing is a VLOOKUP of values 1 through 10 against the results of the RANK formula. The problem coming in is when there is a tie. Take the below for example:

    Category One 192
    Category Two 139
    Category Three 139
    Category Four 98
    Category Five 212

    So, with the above example the RANK formula would give both Category Two and Three a rank of 3 then skip rank 4 and give Category Four a rank of 5. So, when the VLOOKUP goes looking for the 4 it doesn't find it and errors out.

    What I am looking for a formula that will take those 50 values and rank the top ten without duplicates.

    Hope you can help!!
    Last edited by NBVC; 08-24-2010 at 04:46 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Eliminate Duplicates In Rank Formulas

    You mean something like:

    =RANK(A1,$A$1:$A$10)+COUNTIF($A$1:A1,A1)-1

    copied down

    Adjust ranges to suit.

    This should give unique ranks and not repeat rank numbers.
    Last edited by NBVC; 08-24-2010 at 07:44 AM. Reason: Type in formula (see Martin's comments)
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    04-06-2006
    Posts
    131

    Re: Eliminate Duplicates In Rank Formulas

    You are a genius, my friend.

    Thank you!!!

    :D

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Eliminate Duplicates In Rank Formulas

    Please remember to mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Eliminate Duplicates In Rank Formulas

    Hi NBVC,
    I tried your formula - see attached.
    What am I doing wrong?
    Attached Files Attached Files

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Eliminate Duplicates In Rank Formulas

    =RANK(A1,$A$1:$A$10)+COUNTIF($A$1:A1,A1)-1 in b1
    not
    =RANK(A1,$A$1:$A$10)+COUNTIF($A$1:A10,A1)-1
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Eliminate Duplicates In Rank Formulas

    Thanks Martin,

    I must have copied and pasted the last formula in my test range instead of the first that should have been copied down..... I guess the OP figured it out.

  8. #8
    Registered User
    Join Date
    01-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Eliminate Duplicates In Rank Formulas

    Hey All,

    I have seen this method before and I have always seen it work. Does anyone know if it breaks down if there are MANY duplicates (most of which are 0 or close to 0). I have attached an example from my data where multiple duplicates appear in the ranking.

    I am just curious as to why this would happen but in terms of solution I do not want to add a dummy column and I need rankings.

    Any help would be appreciated.


    Thanks!
    Attached Files Attached Files

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Eliminate Duplicates In Rank Formulas

    1.your formula is starting in the wrong place
    it should be
    =RANK(C2,$C$2:$C$4098)+COUNTIF($C$2:C2,C2)-1
    but you are right it seems that countif () on rows 216 and 224 6.55738E-06
    counts those as the same but rank() sees them as different
    it is probably the way the number is stored from your original data. and excels precision

  10. #10
    Registered User
    Join Date
    01-31-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Eliminate Duplicates In Rank Formulas

    Thanks! That is sort of what I figured. I think I'll be alright with the ranking it is giving since I don't care too much about the 0's and low numbers. I appreciate the info though.

    - Melk

  11. #11
    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,942

    Re: Eliminate Duplicates In Rank Formulas

    melknothink, for future reference, please do not post a question in the thread of another member -- start your own thread

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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