0
votes

Within my crystal report details section i have several values from the field amount, i added a simple formula field to my group header to calculate the SUM({Amount}) Which works however i only want it to SUM the positive values.

There is always a negative version of the positive.

Data

10
30
60
-10
-30
-60

Current Output with SUM({Amount})

0

Desired Output

100

Something like but in crystal variant

SUM({Amount}) FROM mytable WHERE {Amount} > 0
3
Looks like a case statement might work stackoverflow.com/questions/13134230/… Perhaps soemthing like Sum(case when {amount}>0 then {amount} else 0 end) or forums.asp.net/t/… - xQbert

3 Answers

1
votes

You can use two formula to fulfill ur requrement

1.@Positive_Number

if{Table.amount} > 0 then {Table.amount} else 0

2.@Sum_of_PositiveNumber

Sum ({@positive_Number})

thanks Ankur

1
votes

Another option would be a running total that sums the {Table.amount} and evaluates on a formula. {Table.amount} > 0 reset on group if your report is grouped

0
votes

What i did was create a new parameter called ABSAmount :

ABS({AMOUNT})

Then another

SUM({@ABSamount})/2

This gave me the required output.