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?
didier20Asked:
Who is Participating?
 
Sjef BosmanGroupware 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
 
Sjef BosmanGroupware 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
 
Sjef BosmanGroupware 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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
p_parthaCommented:
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
 
CRAKCommented:
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
 
didier20Author 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
 
didier20Author Commented:
Thanks,

It works fine.
0
 
CRAKCommented:
> I think that the string-concatenation is taken instead of addition.....

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.

All Courses

From novice to tech pro — start learning today.