what does it mean (--) in sumproduct formula

learning_grexcel

Active Member
Joined
Jan 29, 2011
Messages
319
I'm just learning sumproduct from different free online sources. I notice that the following two formulas produce same result.

I wonder if there is any difference between them and what occasions we put (--) usually.



= sumproduct((D1:D5) * (B1:B5 = "x") * (C1:C5 = "123"))


=sumproduct (--(B1:B5="x"), --(C1:C5="123"), (D1:D5))
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
-- coerces an array of False/True to an array of 0/1 that sumproduct can evaluate. Using -- is more efficient than *
 
Upvote 0
Whenever you put -- in the front of the parenthesis, it changes all of the True values in the parenthesis to the value 1.
 
Upvote 0
I'm just learning sumproduct from different free online sources. I notice that the following two formulas produce same result.

I wonder if there is any difference between them and what occasions we put (--) usually.



= sumproduct((D1:D5) * (B1:B5 = "x") * (C1:C5 = "123"))


=sumproduct (--(B1:B5="x"), --(C1:C5="123"), (D1:D5))

In your example they will give different results if you have a non-numeric value in column D.

For ex., assume that you write prices for articles in column D. If you write "No longer in catalog" in D3, the first formula will error out while the second one will simply ignore that value.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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