
1. Re: Math Function to sum only positive or negative Numbers
try67 Dec 3, 2013 1:41 AM (in response to kbNetCom)You need to iterate over all the fields, checking if they're positive or negative, and then adding them up. It's not complicated.

2. Re: Math Function to sum only positive or negative Numbers
kbNetCom Dec 3, 2013 1:42 AM (in response to try67)Gilad ....
sorry  I didn´t realize it.
Thanks a lot !!!!!
Kind regards,
Klaus

3. Re: Math Function to sum only positive or negative Numbers
kbNetCom Dec 3, 2013 4:46 AM (in response to kbNetCom)Hello Gilad,
sorry, but I thought:  Yes, this sounds good and logical!
But I think, I am making mistakes.
if ("Gesamt_Preis_01"<0;"Gesamt_Preis_02"<0;"Gesamt_Preis_03"<0;"Gesamt_Preis_04"<0); event.value = "";
or ??
sumif (Number("Gesamt_Preis_01")<0);Number("Gesamt_Preis_02")<0);Number("Gesamt_Preis_03")<0);N umber("Gesamt_Preis_04")<0)); event.value = "";
I hope my intension is not far away from the truth :).
Thank you ....
Klaus

4. Re: Math Function to sum only positive or negative Numbers
Test Screen Name Dec 3, 2013 4:50 AM (in response to kbNetCom)You are trying to do in one expression something that needs lots of statements. Use an if statement to test each element in turn ("iterate over them").

5. Re: Math Function to sum only positive or negative Numbers
kbNetCom Dec 3, 2013 5:28 AM (in response to Test Screen Name)Sorry ... I am not sure to understand, what you mean with "iterate over them" ....
Isn´t it correct, in "calculation" to mark all fields which have to be checked, then to check every Field in "validation" with:
if (a<0; b<0; c<0) ; event.value="";
or is it more like:
if (number(a<0); number(b<0); Number(c<0)) ; event.value="";
I am sorry, but I have tried this  without success :(.
Thanks for a short help !!
:)

6. Re: Math Function to sum only positive or negative Numbers
Test Screen Name Dec 3, 2013 5:32 AM (in response to kbNetCom)No, neither one is anything like JavaScript. You cannot make lists of things to process in this way. They must be done one at a time and written that way.
First set a total to zero.
Write one separate line for each field, adding to the total only if the value is applicable.
To "iterate over" something is to do the same thing for each separate element in it, but to do the thing separately.

7. Re: Math Function to sum only positive or negative Numbers
kbNetCom Dec 3, 2013 5:44 AM (in response to Test Screen Name)Hmmm .. :),
probably I understand a bit more. Just to "set a total to zero"
e.g.
every field has to be checked out ...
if(number(a<0); event.value="";
if(number(b<0); event.value="";
if(number(c<0); event.value="";
Do you mean it in this way .. ??
I gonna try this :).
Thanks

8. Re: Math Function to sum only positive or negative Numbers
Test Screen Name Dec 3, 2013 5:55 AM (in response to kbNetCom)No, not really. Understand that setting event.value is what you do with the final result; you do it once only at the end.
Have a variable, we'll call it total.
You set a variable to zero in the usual way, probably with a var statement.
Then you have a series of if statements, each one adding to total if and only if you need to. I have no idea what number() means or what number(a<0) is supposed to mean, nor how you get the values. This doesn't look anything like JavaScript to me, I think you may be trying to borrow too much from another language you understand better. You need to learn JavaScript if you are to write it!

9. Re: Math Function to sum only positive or negative Numbers
kbNetCom Dec 3, 2013 6:05 AM (in response to Test Screen Name)... ok. I think you are right. It seems to be a mixture of my better known Visual Basic and Excel functions ...
Well, I will try now to find out how I have to write it.
Thanks a lot for your patience.
I will tell you the result  maybe tomorrow.