explanation of dashes

rs2k

Well-known Member
Joined
Aug 15, 2004
Messages
1,413
Could anyone point me in the right direction or explain what the two dashes mean in some formulas, (an example below has been copied from a random post)
=SUMPRODUCT(--($A$2:$A$10=G$2),--($B$2:$B$10=$F3),$C$2:$C$10)

Thanks
Colin.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
rs2k said:
Could anyone point me in the right direction or explain what the two dashes mean in some formulas, (an example below has been copied from a random post)
=SUMPRODUCT(--($A$2:$A$10=G$2),--($B$2:$B$10=$F3),$C$2:$C$10)

Thanks
Colin.

That "random post" wasn't that random... :LOL:

See:

http://www.mrexcel.com/board2/viewtopic.php?t=73205

At the risk of repeating what is already known, the syntax of SumProduct is:

SUMPRODUCT(Array1,Array2,...)

SumProduct multiplies the arrays it is given. The result of that multiplication is also an array, which SumProduct sums. Multiplication and summing say it all: Those arrays must all be numeric, that is, consist of numbers.

If you use a CONDITIONAL like

$A$2:$A$10=G$2

instead of a numeric array, the result of the evaluation of the conditional will be an array/vector of truth values, something like:

{TRUE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}

an object SumProduct cannot do multiplication with. Fortunately, as we know, Excel also have numeric equivalents for the truth values of TRUE and FALSE.

We also know something called COERCION, that is, changing from one data type to another. In case of the truth values, the following effects coercion from logical to numeric equivalents:

=--TRUE ===> 1
=TRUE+0 ===> 1
=TRUE*1 ===> 1
=TRUE^1
=N(TRUE)

If you substitute FALSE for TRUE above, youl'll get 0.

From above:

--($A$2:$A$10=G$2)

will give:

{1;0;0;0;1;0;0;0;1}

0's help to eliminate irrelevant numbers in other arrays/vectors.

Note that the so-called "array formulas" operate the same way.

Edit for typo's.
 
Upvote 0
Many thanks for the replies,
I will go and play with it for a bit now.

Cheer's
Colin.
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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