# How to count with field values?

I have four fields: a,b,c,d.
The value of Field "a" should be (b*c-d)
Field "a" is computed when composed.
But it doesn't work, I get an error message:
Field a: Incorrect data type for operator or @Function.
It's strange because when I enter b+c+d, it works fine.
What is to trick to count with field values?
###### Who is Participating?

Groupware ConsultantCommented:
C'est bizarre...

I tried it myself, and you're right (of course): why the addition is more forgiving than the multiplication puzzles me. I think that the string-concatenation is taken instead of addition, which leads to an empty string result, which is a valid value for a number field. Since there is no alternative meaning for the multiply-operator, you're bound to get an error.

Solution:
x:= b*c*d;
@If(@IsError(x); ""; x)
0

Groupware ConsultantCommented:
Can you give the whole formula, svp? It seems your syntax is wrong somewhere.

By the way, if a field is Computed when Composed, it will be calculated only once: when composed, and never again.
0

Groupware ConsultantCommented:
Following conditions are also important:
- all your 4 fields must be of a numeric type
- all fields must have a content
- all contents must be valid numeric values
0

Commented:
Since a is computed when composed, it's sure that either b or c or d , doesn't have value and a should be below all this fields.

Partha
0

Commented:
Didier20, does this occur on a specific (let's say newly composed) document, or in an agent running on a bunch of documents. I'd like to rule out that (b*c-d) was fired on a different document than b+c+d: if one of these computations fails, I'd expect the other to fail on the very same document as well! If one succeeds, the other one should do so to!
0

Author Commented:
Case 1 (just for test) (a = b+c+d)
When I open the database and click "New Request" the Form will be opened and if I set the values e.g. b=10, c=5, d=3 and press Ctrl+S, then the value of a=18 and no error message.

Case 2 (a = b*c*d) (I did nothing else only replaced "+" with "*")
When I open the database and click "New Request" I get immediately the error message:

Field a: Incorrect data type for operator or @Function: Number expected

The fields b,c,d, are below the field a.
The property of the fields b,c,d: number and editable.
Field "a" is number and Computed (I changed it)

Please tell me why the values can be added to each other but not multiplicated.

0

Author Commented:
Thanks,

It works fine.
0

Commented:

Good guess. 0 + b + c + d raises the error right away!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.