Jasper report variable printing zero value

I am working on a jasper report in which I am using following SQL query:
    select SOURCE, count(*) as total
    where UPLOAD_DT >= '20150601'
    and UPLOAD_DT <= '20150630'
    group by SOURCE
    order by SOURCE
and the result is:
    "New Application";15
    "Periodic Report";16
I have created variable like:
    <variable name="PR" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[($F{source} == 'Periodic_Report') ? $F{total} : 0]]></variableExpression>
This variable is printing zero value each time.
If I change conditional clause as follow:
   <variable name="PR" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[($F{source} == 'Periodic_Report') ? 0 : $F{total}]]></variableExpression>
Then its printing SUM 56 of TOTAL column.
Can someone please tell me what is wrong here?
daad.madhusudan's picture
Joined: Mar 13 2015 - 4:36am
Last seen: 4 years 1 day ago

Why you wrote at jaspersoft and stackoverflow the same wrong (uncorrect) question? You can't get right answer with this description.
You're wasting people's time. You must correct mistakes and show fields declarations. And show result with $F{source}.equals("Periodic Report")

sanbez - 5 years 1 month ago

1 Answer:


Should be using ".equals(object)" if you're using Java as your report language.

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 2 months ago