
1. Re: Script to make calculation show $0, if result negative
philmodjunk Oct 13, 2010 10:44 AM (in response to dg3321)You don't really need a script for this in most cases.
This calculation will replace negative values with zero:
max ( //put your calculation here ; 0 )

2. Re: Script to make calculation show $0, if result negative
dg3321 Oct 13, 2010 12:52 PM (in response to dg3321)that worked perfectly, thanks!

3. Re: Script to make calculation show $0, if result negative
dg3321 Oct 13, 2010 1:28 PM (in response to dg3321)Update:
The calculation worked in that when the result was negative, it showed $0.
However, when i used that field in a sum calculation, it seems that the sum calculation is interpreting the field with a negative number as negative, instead of zero. How do i fix that?

4. Re: Script to make calculation show $0, if result negative
philmodjunk Oct 13, 2010 1:33 PM (in response to dg3321)Please give an example of how you are using the sum calculation. What you are describing should not be the case, but there are a number of different ways to calculate a "sum" so I need to see exactly what you've done before I can offer a fix to you.

5. Re: Script to make calculation show $0, if result negative
dg3321 Oct 13, 2010 1:43 PM (in response to dg3321)i actually got it to work by using a '+' sign, instead of doing 'sum (field 1, field 2 etc...).
Why did it work w/ the + sign but not the sum calculation? Do they mean different things?

6. Re: Script to make calculation show $0, if result negative
philmodjunk Oct 13, 2010 1:50 PM (in response to dg3321)Sum ( field 1 ; field 2 ; field 3 ) and Field 1 + field 2 + field 3 will give you exactly the same results.
Sum ( relatedTable::Field ) on the other hand, adds up the values of Field from all related records.

7. Re: Script to make calculation show $0, if result negative
dg3321 Oct 14, 2010 6:03 AM (in response to dg3321)The fields that were part of the calculation were all related fields. does that mean I should use the + sign for all related field calculations in which I need a sum? 
8. Re: Script to make calculation show $0, if result negative
philmodjunk Oct 14, 2010 8:11 AM (in response to dg3321)That's not a question I can answer fully without knowing the structure of your database.
If you have a calculation such as RelatedTable::Field1 + RelatedTable::field2, you are adding data the "first" such related recordsomething that is controlled by what options you've selected in your relationship. Whether the first related record is the correct one for the results that you want is the part I can't tell you.
The Sum function, on the other hand, adds up all the related recordsso this at least explains why you were getting different results.
Note: if all the fields you are adding together come from the same related table, you should define this calculation in the related table instead of where you have defined it now.