Matt
Matt

Reputation: 15061

Crystal Reports Formula fields SUM only positive values using WHERE

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

Upvotes: 0

Views: 3320

Answers (3)

CoSpringsGuy
CoSpringsGuy

Reputation: 1645

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

Upvotes: 1

Matt
Matt

Reputation: 15061

What i did was create a new parameter called ABSAmount :

ABS({AMOUNT})

Then another

SUM({@ABSamount})/2

This gave me the required output.

Upvotes: 0

Ankur Alankar Biswal
Ankur Alankar Biswal

Reputation: 1182

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

Upvotes: 1

Related Questions