+ Reply to Thread
Results 1 to 15 of 15

Frequency function to correct ranking instead of countif

  1. #1
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Frequency function to correct ranking instead of countif

    Unresolved Cross post from :

    http://www.mrexcel.com/forum/excel-q...d-countif.html

    Hello,
    I have been using countif to rank numbers across +20 000 rows (+100 000 rows before data cleanup). Needless to say, this countif function is slowing down my model to a point it even crashes my excel. To fix this, I am trying to find a way to use the frequency function.

    Below is an example of the desired results using countif in column C :

    In C2, I use the classic : =COUNTIF(B$2:B2,B2)-1, which I copy down to the last row. (sorry but the paste and format functionalities on this site are not helping)

    A B C D
    1 values rank rank adjustment real rank
    2 100 7 0 7
    3 200 6 0 6
    4 300 5 0 5
    5 420 2 0 2
    6 500 1 0 1
    7 420 2 1 3
    8 310 4 0 4



    Now for the frequency version, the following forumula is wrong, but I understand it needs to look a little something like this, in C2 :

    {=SUM(IF(FREQUENCY(IF(B$2:B2<>"",IF(B$2:B2=B2,MATCH("~"&B$2:B2,B$2:B2&"",0))),ROW(B$2:B2)-ROW(B$2)+1),1))-1}


    Tons of thanks in advance for your kind help !

    Scott
    Last edited by Scottlarock; 08-01-2013 at 07:09 PM.

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

    Re: Frequency function to correct ranking instead of countif

    im not sure why you need frequency()
    you can get that result by
    =RANK(A2,$A$2:$A$25000,0)+COUNTIF($A$2:A2,A2)-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

  3. #3
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Frequency function to correct ranking instead of countif

    Hi Martin,

    thx for your reply, the whole point is to avoid countif.
    I know how to use countif, but this function, in case you didn't know will slow large models up tremendously.
    If you or anyone can help me figure out a way to use a function based on frequency for a similar result as my above post using countif, it would be fabulous.

    Tons of thx again.
    Scott

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

    Re: Frequency function to correct ranking instead of countif

    it wont slow it as much as any array formula you use

  5. #5
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Frequency function to correct ranking instead of countif

    I have heard otherwise on one of the excellis fun vids... and I won't ever know until I test it out will I ? I can tell you it is super obvious this function gets incredibly heavy with large data sets.
    Anyway, thanks for your help.
    Scott.

  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: Frequency function to correct ranking instead of countif

    cross post at
    http://www.mrexcel.com/forum/excel-q...d-countif.html

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

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

    Re: Frequency function to correct ranking instead of countif

    =RANK(A2,$A$2:$A$50)+INDEX(FREQUENCY($A$2:A2,$A$2:A2),MATCH(A2,A$2:A2,0))-1
    gives same result as
    =RANK(A2,$A$2:$A$50)+COUNTIF($A$2:A2,A2)-1
    mind you on 25000 rows it took about 3 times longer to calculate

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Frequency function to correct ranking instead of countif

    The YouTube vid that you talk about http://www.youtube.com/watch?v=_cWg850PMys is the fastest for large spread sheets according to the presentation.

    The SUMIF, COUNTIF AND AVERAGEIF functions are much faster than their predecessors.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  9. #9
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Frequency function to correct ranking instead of countif

    Really ? that's what you do ? So you actually spent time to post this and threaten to close my thread...
    The reason I "cross" posted in here is because I was NOT getting the feedback I am looking for from the other forum. And the reason it did not go "unnoticed" is because I purposely tagged it well ! Now the fact that I am replying to your posts minutes after you posted them kind of means that I am on top of things... dows it not.
    From your replies you sound more like someone trying to gain credits to get certified.... And I could tell you the same BS, guess what, posting a (useless)reply actually leads forum readers to believe that a solution has been found - so now I have no other option but to go through the process again... thx.
    Anyway, thx for the attempt, but unfortunately, if you had actually read my post you would have noticed that I am using the exact formula you provided in your first post.... smarty pants.

  10. #10
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Frequency function to correct ranking instead of countif

    Hello Ontario...
    thx for the reply.
    The video I am referring to is not that one, but rather this one :
    http://www.youtube.com/watch?v=uUrI8hoj8BA

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

    Re: Frequency function to correct ranking instead of countif

    you agreed to the rules before you posted if you cant be bothered to abide by them i cant be bothered to help

  12. #12
    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,932

    Re: Frequency function to correct ranking instead of countif

    Scottlarock, might I suggest slightly less sarcasm in your posts here? You are new to the forum, and perhaps did not pay quite as much attention to the rules as you might have when you read them?

    ALL members here offer their time and effort free of charge, we are all here to help each other, and politeness is a requirement here. Perhaps adherance to the old adage...if you cant say anything nice, dont say anything...would be worth following

    As far as I can see, 2 very experienced members have offered some very good suggestions and advice to you, most members would take the time to test them, before rejecting them in favor of what some-one else "said".

    Thanks to taking the time to read this )
    Last edited by FDibbins; 08-01-2013 at 10:26 PM. Reason: typo
    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

  13. #13
    Registered User
    Join Date
    08-20-2012
    Location
    Zurich
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Frequency function to correct ranking instead of countif

    I suppose its's a big misunderstanding. Sorry for comin across as a jerk - but I got offended, I am actually a very patient and polite guy.. to me, common sense dictates the rules - no need to pull out red cards just for the kick of it.
    There was no sarcasm in my post, just pointing out the fact that the threats were uncalled for - hey, if you don't want to answer ? Then by all means, DON'T ANSWER !!!!!!

    Anyhoo.. back to the essentials - the vid link I posted up there is not the exact one in which I heard something very relevant to me, that is to say, that COUNTIF will slow models down tremendously if used on Large data sets as opposed to a nested frequency function. I can attest it is true. This is the right vid link, jump to 01 min 25 :

    http://www.youtube.com/watch?v=3u8VHTvSNE4

    Btw, yes I am new to this forum - thanks for chasing me away.

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

    Re: Frequency function to correct ranking instead of countif

    INDEX(FREQUENCY($A$2:A2,$A$2:A2),MATCH(A2,A$2:A2,0))-1 does the same thing no array entered needed
    but it is slower ,even making array formulas is not always a way for speed
    rank() itself is slow on big data sets then add countif it gets slower still
    now if there is away to combine both to both rank and countif to produce unique rank using frequency instead i admit i dont know it
    but this i dont understand
    gain credits to get certified.
    this forum has nothing to do with MS and the only certification i'll get is when i turn down a free drink for no reason
    the quickest way i can see is to do the rank as normal
    then use countif()-1 on the results
    Last edited by martindwilson; 08-02-2013 at 06:01 PM.

  15. #15
    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,932

    Re: Frequency function to correct ranking instead of countif

    1st, there was no threat made to you, Martin posted a copy of the rule that you failed to adhere to. Thats what the rule said, and thats all Martin was pointing out to you - something that you should have read when you joined.

    2nd, if you think that giving me a negative rep, with the comment "Complete loser, intervenes with no purpose but to play captain america." attached will earn you more respect here, or that it would offend or bother me in any way, good luck with that

    If I had to make a choice between taking the advice of some video posted on youtube (which literally anyone can do) and following the proven advice of most of the members here...hey, but thats my choice to make, right?
    Last edited by FDibbins; 08-03-2013 at 11:21 PM.

+ 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. Looking for a correct COUNTIF function
    By Smit22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-26-2012, 02:02 PM
  2. Frequency + Ranking Function.
    By myteam in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-26-2010, 04:33 AM
  3. Counting frequency and ranking
    By themax16 in forum Excel General
    Replies: 3
    Last Post: 03-24-2009, 07:32 AM
  4. Formula 4 ranking by frequency
    By zenmanic in forum Excel General
    Replies: 1
    Last Post: 11-20-2008, 11:49 AM
  5. Ranking based on frequency
    By mac_see in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2006, 12:55 PM

Tags for this Thread

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