is there another alternative, IF SUMPRODUCT ?

Blvkcage

New Member
Joined
Jan 14, 2020
Messages
6
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi all,
Need some info on "IF SUMPRODUCT" formula.
This formula help me validate my data for 1 year but this formula can slow down calculation considerably and take long time for me to report.
is there something better than if sumproduct?

An example of a formula is this:
=IF(SUMPRODUCT(($B$3:$B3=B3)*($B$3:$B3=B3))>1,0,1)
 

Attachments

  • Image 1.jpg
    Image 1.jpg
    69 KB · Views: 14

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Welcome to MrExcel Message Board
Test This
Excel Formula:
=IF(COUNTIF($B$3:$B3,B3)=1,1,0)
 
Upvote 0
Welcome to the MrExcel board!

On of the reasons that your formula slows your sheet is that it is doing the identical cell comparisons twice. For example, in row 10 the formula becomes
=IF(SUMPRODUCT(($B$3:$B10=B10)*($B$3:$B10=B10))>1,0,1)
In that cell it compares eight cells (B3:B10) to B10 but then it compares those same eight cell to B10 again.

So you could roughly halve the calculation time by changing your formula to the following where it only does the comparison once in each formula.
=IF(SUMPRODUCT(--($B$3:$B3=B3))>1,0,1)

However, there are faster ways still.

I did a test with about 10,000 rows.
Your original formula took 9.6 seconds to calculate the column.
The adjusted formula that I suggested above took 4.8 seconds
maabadi's formula took 2.6 seconds
The formula below took 0.8 seconds, so I'd suggest that you give it a go.

Excel Formula:
=1-ISNUMBER(MATCH(B3,B$2:B2,0))
 
Upvote 0
Solution
Welcome to the MrExcel board!

On of the reasons that your formula slows your sheet is that it is doing the identical cell comparisons twice. For example, in row 10 the formula becomes
=IF(SUMPRODUCT(($B$3:$B10=B10)*($B$3:$B10=B10))>1,0,1)
In that cell it compares eight cells (B3:B10) to B10 but then it compares those same eight cell to B10 again.

So you could roughly halve the calculation time by changing your formula to the following where it only does the comparison once in each formula.
=IF(SUMPRODUCT(--($B$3:$B3=B3))>1,0,1)

However, there are faster ways still.

I did a test with about 10,000 rows.
Your original formula took 9.6 seconds to calculate the column.
The adjusted formula that I suggested above took 4.8 seconds
maabadi's formula took 2.6 seconds
The formula below took 0.8 seconds, so I'd suggest that you give it a go.

Excel Formula:
=1-ISNUMBER(MATCH(B3,B$2:B2,0))
hi peter thanks alot for yourhelp ,
another question if the criteria more than 1 row (maybe 2 or 3 row) like image below, what i should to do with this formula "=1-ISNUMBER(MATCH(B3,B$2:B2,0))"

coz i just can do this =IF(COUNTIFS($F$3:$F3,F3,$G$3:G3,G3)=1,1,0) what more took faster..
can u help please.
 

Attachments

  • Image 5.jpg
    Image 5.jpg
    230 KB · Views: 9
Upvote 0
peter thanks alot for yourhelp ,
You're welcome.

another question if the criteria more than 1 row
I think you mean more than one column?
If so, I think your current COUNTIFS formula is probably the fastest

BTW, you will generally get faster/better help if you provide your sample data with XL2BB so that helpers can copy it to test with.
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

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