Search code examples
sqlcrystal-reportscrystal-reports-xi

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

Solution

  • What i did was create a new parameter called ABSAmount :

    ABS({AMOUNT})
    

    Then another

    SUM({@ABSamount})/2
    

    This gave me the required output.