Using double unary --

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hi

When should I be using this?

I normally throw it into my sumproduct when I get a zero result or an error, to force the ranges into giving a true/fale 1/0. Normally when there is text within a numeric range or something along those lines

SUMPRODUCT(--(PRODUCTYPE=PRDUCE)*--(LOCATION=THIS),--(COST))

Thoughts?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi

When should I be using this?

I normally throw it into my sumproduct when I get a zero result or an error, to force the ranges into giving a true/fale 1/0. Normally when there is text within a numeric range or something along those lines

SUMPRODUCT(--(PRODUCTYPE=PRDUCE)*--(LOCATION=THIS),--(COST))

Thoughts?

A coercer like -- is used...

(1) when you need to transform an array of TRUE/FALSE's into 1/0's;

(2) when you need to coerce a text-number into a true number.

By the way, do not mix * and -- for they both act as coercers. Thus:

SUMPRODUCT(--(PRODUCTYPE=PRDUCE),--(LOCATION=THIS),COST)
 
Upvote 0
Either use double unary, or use the multiplication, but not both. And don't use the -- on the data range, unless it's numbers stored as text.
 
Upvote 0
Perfect, any more pointers?

I have been using (TEST1)*(TEST2),(RESULT)

Only using the comma on the last method. Does this really matter

The only time I need to use anything else is the + for an OR method?
 
Upvote 0
If you read xld's page that I suggested, he has a whole section on the different coercion methods. In summary, it doesn't really matter, but lots of people prefer the --.
 
Upvote 0
Perfect, any more pointers?

I have been using (TEST1)*(TEST2),(RESULT)

Only using the comma on the last method. Does this really matter

The only time I need to use anything else is the + for an OR method?

Not sure what you mean by TEST1 and TEST2. If they are conditional expressions, we can have:

--(TEST1),--(TEST2),RESULT

(TEST1)+0,(TEST2)+0,RESULT

(TEST1)*(TEST2),RESULT

(TEST1)*(TEST2)*RESULT

OR has to be mapped sometimes on +, but, it can be, more often not,
rewritten as:

ISNUMBER(MATCH(Range,List,0))

Here more links...

http://www.mrexcel.com/forum/showthread.php?t=202204

http://www.mrexcel.com/forum/showthread.php?t=128907

http://www.mrexcel.com/forum/showthread.php?p=1671486

And a first white paper on SumProduct:

http://www.mrexcel.com/forum/showthread.php?t=56778
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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