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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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,215,205
Messages
6,123,632
Members
449,109
Latest member
Sebas8956

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