3 Replies Latest reply on Apr 14, 2011 2:55 PM by philmodjunk

# calc field -- what am I doing wrong?

### Title

calc field -- what am I doing wrong?

### Post

I have the following calc field  (We'll call it RESULT_FIELD)

Sometimes my result is working, sometimes not.

-------------

Case (

FIELD1 = 8 and FIELD2 > 8; "COMPLETE";

FIELD1 = 8 and FIELD2 = 8; "PHASE 2";

FIELD1 = 8 and FIELD2 = 7; "PHASE 1;

FIELD1 = 8 and FIELD2 = 1 or 2 or 3 or 4 or 5 or 6; FIELD2;   /* returns data entered in field2 if true */

FIELD1 = 10 and FIELD2 > 10; "COMPLETE";

FIELD1 = 10 and FIELD2 = 10; "PHASE 2";

FIELD1 = 10 and FIELD2 = 9; "PHASE 1;

FIELD1 = 10 and FIELD2 = 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8; FIELD2;   /* returns data entered in field2 if true */

-----------

in case it matters:

FIELD1 and FIELD2 are number fields; RESULT_FIELD is a text field.

FIELD1 has a validated pull-down list of either "8" or "10"

In general, everything is working when data in FIELD1 is "8"

But NOT working when data in FIELD1 is "10".

What am I doing wrong?

• ###### 1. Re: calc field -- what am I doing wrong?

FIELD2 = 1 or 2 or 3 or 4 or 5 or 6

is always true as nonzero numbers evaluate as true. The above expression is really Field2 = 1 or True or True or True...

Rewrite it as:

Field2 = 1 or Field2 = 2 or Field2 = 3

or possibly:

Field2 > 1 and Field2 < 6

• ###### 2. Re: calc field -- what am I doing wrong?

Thanks Phil.  Should I use additional parenthesis?  such as:

Field1 = 8 and (Field2 = 1 or Field2 = 2 or Field2 = 3); _RESULT_

• ###### 3. Re: calc field -- what am I doing wrong?

The Parenthesis as you've used them won't affect the result. You can use them if it makes the expression clearer to you.

It's my preference to group with parenthesis this way:

( Field1 = 8 ) and ( Field2 = 1 ) or ( Field2 = 2 ) or ( Field2 = 3 )

My brain finds that easier to read as it groups the boolean comparisons and I don't have to stop and ask myself: (what's the order of operations rule that applies here...)