Using =if(countif), slow data, and much more fun!

jasbentle

New Member
Joined
Nov 3, 2017
Messages
3
I have a very large database that I am trying to certain information and am having a problem doing so because of the size.

What I want to accomplish:
I would like two things
1) if Column C, F, and G are the same put "Original" in Column H
2) if Column C, F, and G are the same put but already have an "Original" instance, put "Duplicate" in column H

What I'm trying to accomplish is finding out if any of the text in F is different and if the credits in column G has changed. Here is the formula I put together.
=IF(COUNTIFS($C$2:C2,C2,$F$2:F2,F2,$G$2:G2,G2)>1, "Duplicate","Original")

Great right? It "works" but is so sluggish because I have almost 50K rows of data so any time I make any sort of change, it takes 30 min. or so to update. I have tried turning off auto calculation options

Also, for bonus points if anyone has ideas (that wont bog down the spreadsheet) on how I can have a range if all the information and have it put the YEAR LOW and YEAR HIGH of when all the said data is EXACTLY the same, that would be great!

TIA

Below is the spreadsheet below for reference.

A B C D E F G

20162017AB 205AB205TECHNICAL SKILLS AND COLLISION REPAIR12
20172018AB 205AB205TECHNICAL SKILLS AND COLLISION REPAIR12
20022003AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20032004AB 280AAB280ACE: AUTO BODY REPAIRVARIABLE
20042005AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20052006AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20062007AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20072008AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20082009AB 280AAB280ACE: AUTO BODYVARIABLE
20092010AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20102011AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20112012AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20122013AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20132014AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20142015AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20152016AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20162017AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20172018AB 280AAB280ACOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20022003AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR SEMINARVARIABLE
20032004AB 280BAB280BCE: AUTO BODY REPAIR- SEMINARVARIABLE
20042005AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20052006AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20062007AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20072008AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20082009AB 280BAB280BCE: AUTO BODY REPAIR - SEMINARVARIABLE
20092010AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIRVARIABLE
20102011AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20112012AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20122013AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20132014AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20142015AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20152016AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20162017AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20172018AB 280BAB280BCOOPERATIVE EDUCATION: AUTO BODY REPAIR - SEMINARVARIABLE
20022003AB 9120AB9120AUTO BODY RESTORATION3
20032004AB 9120AB9120AUTO BODY RESTORATION3
20042005AB 9120AB9120AUTO BODY RESTORATION3
20052006AB 9120AB9120AUTO BODY RESTORATION3
20062007AB 9120AB9120AUTO BODY RESTORATION3
20072008AB 9120AB9120AUTO BODY RESTORATION3
20082009AB 9120AB9120AUTO BODY RESTORATION3
20092010AB 9120AB9120AUTO BODY RESTORATION3
20102011AB 9120AB9120AUTO BODY RESTORATION3
20022003AB 9121AB9121VINTAGE AUTO RESTORATION PROCESS2

<colgroup><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
These are untested beyond the 44 lines of the example spreadsheet.

Rewriting the formula to remove the IF might speed things up. Conditional branching can be a cause of slow calculation performance.

H2=REPT("Original",COUNTIFS($C$2:C2,C2,$F$2:F2,F2,$G$2:G2,G2)=1)&REPT("Duplicate",COUNTIFS($C$2:C2,C2,$F$2:F2,F2,$G$2:G2,G2)<> 1)

<tbody>
</tbody>


That's OK but the COUNTIFS is repeated. That part of the formula could be placed into a separate column so that the COUNTIFS is only calculated once per row.

H2=COUNTIFS($C$2:C2,C2,$F$2:F2,F2,$G$2:G2,G2)
I2=REPT("Original",H2=1) & REPT("Duplicate", H2>1)

<tbody>
</tbody>


In the original formula in cell H2, there are three comparison operations being performed.
In cell H3, there are six comparison operations (does C3 equal C2, does C3 equal C2, does F3 equal F2, does F3 equal F3, does H3 ...).
...
In cell H49999 there are 149,997 comparison operations being performed.

You add them all up and by the time Excel gets to H50000, it's completed 3,749,925,000 comparison operations and has another 150,000 to do.

The following might be a speedup; it could make things worse, or it might not make any perceptible difference in speed. Text operations in Excel are slower than numeric operations, but we reduce the number of comparison operations to one-third of the original number by concatenating the column C, F, and G cells in another helper column.

H2=C2&" "&F2&" "&G2
I2=COUNTIF($H$2:H2, H2)
J2=REPT("Original", I2=1) & REPT("Duplicate", I2<> 1)

<tbody>
</tbody>

Note we're now using COUNTIF, without the "S" in cell I2. The ampersand, the "&", in cell H2 is the concatenation operator.


You could convert some of the formulas to values and calculation time would be greatly reduced.
 
Last edited:
Upvote 0
In H2 enter and copy down:

=$C2&$F2&$G2

In I2 enter and copy down:

=IF(ISNA(MATCH($H2,$H$1:H1,0)),"original","duplicate")

This set up should be faster.
 
Upvote 0
Aladin Akyurek,

I am very jealous of your ability to cut through to concise formulas. Perhaps I should try to learn Lisp again?
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,922
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top