i am having trouble getting anything within iReports to work. i am able to do a basic report which displays the value of each field on the page. however, when i try to do any manipulation or calculation with the data, i get errors and nothing works. also, i cannot get the chart tool to work either. any advice/suggestions would be greatly appreciated. we are about at the point where we will have to use a different reporting tool.
scenario 1 -- trying to get a count of the number of records where a particular field equals a specified value
scenario 2 -- trying to get a pie chart which compares the various values/results of a particular drop down field
scenario 3 -- trying to get a sum of order amount for a given range of orders
Code: |
scenario 1 -- entered in the variable expression -- $F{cases_priority}.contains( "P1" ) scenaro 2 -- entered in the key expression $F{cases_priority} --entered in the value expression $F{cases_priority}.contains( "P1" ) --entered in label expression $F{cases_priority} scenario 3 -- not yet tried</td></tr></tbody></table> |
7 Answers:
i have tried that BUT the variable expression is not working correctly so i get an error and the count/sum does not work.
the variable i set up -- count_cases_priority_1 -- has a varible expression of
$F{cases_priority}.contains( "P1" )
but when i try to execute the report using the active conneciton i get an error -- Cannot cast from boolean to Object
i am totaly stuck and do not know what else to try or where to go for help. we purchased the "The Ultimate Guide to iReport " but it does not help much.
First of all I strongly suggest you to set as language for the report Groovy (in the report properties). In this way you can forget about the complexity of some expression with Java.
scenario 1 -- entered in the variable expression --
a) Create a new variable
- Class: Integer (we are doing a count)
- Calculation: Count
- Variable expression: $F{cases_priority}.contains( "P1" ) ? $F{cases_priority} : null
- (Optional) Initial Value Expression: 0
Just a note about the variable expression: the count calculation add 1 if the expression is not null, 0 otherwise, so the if condition return something that is supposed to be not null ($F{cases_priority}) if $F{cases_priority} contains P1 otherwise return null.
scenario 2 -- trying to get a pie chart which compares the various values/results of a particular drop down field
Not sure what do you mean.,,,
scenario 3 -- trying to get a sum of order amount for a given range of orders
a) Create a new variable
- Class: Double
- Calculation: Sum
- Variable expression: $F{myAmountFiled}
- (Optional) Initial Value Expression: 0.0
Giulio
your suggestions on scenario #1 did the trick. it is working now. THANKS!!!
for scenario #2 - i want to create a pie chart that shows the total number of each value for cases_priority (those are P1, P2, etc). i have used the following setup --
key expression -- $F{cases_priority} ==> this works and shows the various categories available within the database EXcEPT for categories where there are 0 records matching that category
value expression -- this is where i am stuck -- i just want the chart to use the total count of each category as the value here BUT i cannot get the expression to evaluate correctly. i have an individual count for each category separately (for example 65 occurances of P1) but no way to have it select a category and then count the occurances of that value. i need a way to express a count of each cases_priority and sort by the value of cases_priority (ie. P1, P2, P3, etc).
Create a variable for each Priority field (P1, P2, P3...) to count the occurrences.
Create a pie chart, evaluation time: Report
Edit the chart data:
Increment type: Report
In the details tab click on Use more series. Create series for each Priority, using the priority name as key (like "P1") and the relative variable value as value.
That's it.
Giulio