-1

I was wondering how I can sum values in Ireports For example I have some "null" and some values (5,10,200..etc) I want to sum them in a third column .

I have $F(field1) - 5 $F(field2) - Null $(field3) - Null So in total , no matter that I have '5' as result from 'Field1' - I always get "Null" (After running the jasper ) Picture1 Picture2

Please check screenshots

Thank you so much!

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • 1
    Possible duplicate of [How to sum all values in a column in Jaspersoft iReport Designer?](https://stackoverflow.com/questions/13550514/how-to-sum-all-values-in-a-column-in-jaspersoft-ireport-designer) – Alex K Jun 27 '17 at 13:07
  • `<![CDATA[$F{field1} != null ? $F{field1} : 0]]>` - for int type – Alex K Jun 27 '17 at 13:10

1 Answers1

2

To calculate sum for Total column use following expression:

($F{field1} == null ?  0:$F{field1}) + ($F{field2} == null ?  0:$F{field2}) +($F{field3} == null ?  0:$F{field3})

You may need to convert this variables into the respective datatypes. (Integer or Double)

Mayur Bhokase
  • 377
  • 4
  • 19