Search code examples
crystal-reportscrystal-reports-2008crystal-reports-2010

Conditional Sum and Count in Crystal Reports


Is there any way that I can change a formula field with this code:

if(isnull(sum({col1}))) then
0
else
sum({col1})

to something like: sum(col1) WHERE col2='a'? I would like to calculate only some rows in the sum based on a value of another column.

In case there is, please provide me with syntax or the way to do it.

P.s: in case it matters I'm using CrystalReports 13.0 whith Visual Studio 2010


Solution

  • You can do something like this.

    In details write formula

    If col2='a'
    Then col1
    Else 0
    

    Now take the sum in footer