+ Reply to Thread
Results 1 to 4 of 4

countif in a large file

  1. #1
    Registered User
    Join Date
    09-29-2020
    Location
    Sweden
    MS-Off Ver
    1808
    Posts
    2

    countif in a large file

    Hi,

    I have a large file and i need to know how many times each value in column C occurs in that column and I would like to have that number in column B.
    I've tried to use =COUNTIF($C$2:$C$84185;C2) but excel usually crashes and if it don't it takes ALOT of time to calculate. Is there any better method to do this? I would be very grateful for and help or tips

    my file looks like this
    A B C
    87183796SE 917311953 PostNord Parcel 71331
    87174914SE 917312941 PostNord Parcel 25227
    87131014SE 917314664 PostNord Pallet Helpall 90742
    87181031SE 917314664 PostNord Pallet Helpall 90742
    83100470SE 917315104 PostNord Parcel 58725
    87145122SE 917317581 PostNord Pallet Helpall 25466
    87109098SE 917318689 PostNord Parcel 11157
    87183706SE 917318739 PostNord Parcel 43153
    87185323SE 917319561 PostNord Parcel 57431
    87183118SE 917322086 PostNord Parcel 17561
    87183144SE 917325262 PostNord Parcel 78477
    Last edited by Matglad; 09-29-2020 at 05:05 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: countif in a large file

    Difficult to say without seeing the file. Standard non array functions are usually about as efficient as you can get without using a Pivot Table

    Have you tried a PT? They're more efficient than functions IMO
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-29-2020
    Location
    Sweden
    MS-Off Ver
    1808
    Posts
    2

    Re: countif in a large file

    I need to futher process the data after so i rather not use a PT if its possible. il try to attach a sample of the file
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: countif in a large file

    Countif (and Countifs) does seem to be slow with 84k rows of data.
    Vlookup on the other hand, isn't.
    You can use a Pivot table (or a Power Query query) as a lookup table.
    I used 130k rows of data, one set with almost as many distinct items as there are rows of data (like your data), and another set with only 16 distinct values.
    The first set makes for a big lookup table, and for this, the pivot table was faster at updating than the Power Query (although Power Query wasn't that slow).
    For the second set the difference wasn't noticeable.

    Using a Pivot table as a lookup table isn't that easy as the size of the table varies with your source data and there's no super easy way to refer to the Pivot table's range changes.
    Using a VLookup on a Power Query query is super easy because the reference to the query table remains the same, regardless of its changing size.

    Whether you use the pivot or the query it needs to be refreshed if the source data changes (this can be automated). Right-clicking and choosing Refresh does this manually.

    In the linked-to file here, (too big to attach I suspect) I've included both methods, and a tiny macro to give the name PVLookup to the pivot table range straight after the pivot's been refreshed, which name is used in column A.

    The Power Query query is short and straightforward.
    The 260k formulae in columns A and B take a trivial amount of time to update.

    Other things I tried:
    Advanced Filter to get a unique list of numbers - very slow indeed
    GetPivotData formula - very slow

+ 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. SUMIF for Large Dataset
    By nobodyukno in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2018, 12:09 AM
  2. =SUMIF and LARGE(array,n) HELP
    By minhtran1085 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-29-2016, 06:57 PM
  3. [SOLVED] SUMIF Function for a large group of file numbers
    By kas05j in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-06-2015, 05:12 AM
  4. Sumif - large range
    By ndreid2003 in forum Excel General
    Replies: 1
    Last Post: 03-21-2014, 12:48 PM
  5. SUMIF and LARGE
    By rudypoochris in forum Excel General
    Replies: 2
    Last Post: 12-28-2011, 02:00 PM
  6. Large function & Sumif
    By kmsoni in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2011, 03:19 PM
  7. [SOLVED] Sumif + Large = headache
    By Hops in forum Excel General
    Replies: 5
    Last Post: 11-27-2005, 06:10 AM

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