Jasper report variable printing zero value

0
I am working on a jasper report in which I am using following SQL query:
 
    select SOURCE, count(*) as total
    from CASE_UPLOADS
    where UPLOAD_DT >= '20150601'
    and UPLOAD_DT <= '20150630'
    group by SOURCE
    order by SOURCE
 
and the result is:
 
 
    SOURCE,TOTAL
    "New Application";15
    "Periodic Report";16
    "RD/RC";25
 
I have created variable like:
 
    <variable name="PR" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[($F{source} == 'Periodic_Report') ? $F{total} : 0]]></variableExpression>
</variable>
 
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>
</variable>
    
 
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: 3 years 2 months 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 - 4 years 3 months ago

1 Answer:

0

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

hozawa's picture
50828
Joined: Apr 24 2010 - 4:31pm
Last seen: 4 months 5 days ago
Feedback
randomness