juser73 Posted August 17, 2010 Share Posted August 17, 2010 So i have a report that includes, username, employee number, sum of hours(for each employee), and difference of average hours...I have a parameter so you can select which dates you want to view the employee hoursAt the end of the report i have the average of total hours '$V{sum_5}' for the time period selectd (i.e. 5/01/2010-5/02/2010)I want the difference of average hours to display if each individual employee worked above or below the total average hours and what that difference is... For the variable i created i create a variable '$V{SUM}' which is equl to the individual hours for each employee..Then i created another variable '$V{aboveave}' which is supposed equal the hours for each individual employee - the total average hours for the selected dates, so I put the variable expression to... '$V{SUM}.subtract( $V{sum_5} )' But when I click preview the differences are all wrong and im not sure where the report is getting the information from, here's an example from my report (its only part of the report, but the average is correct for the entire report)... username employee number sum of hours difference of hoursuser1 a1 3.00 0.00user2 b2 6.00 1.50user3 c3 .67 -3.53user4 d4 9.16 4.01 average of all hours: 5.15Post Edited by juser73 at 08/17/2010 19:03 Link to comment Share on other sites More sharing options...
slow Posted August 18, 2010 Share Posted August 18, 2010 you need only one variable that makes an average of worked hours.suppose we call it$V{avg_hours} then, if you want to show the difference between the single employee hours ($F{HOURS}) and this average value ($V{avg_hours}), create a textfield with BigDecimal type putting this expression (equal to the expression you use)$F{HOURS}.subtract($V{avg_hours} )then set the evaluation time to AUTO.in this way it works.when you set the evaluation time to NOW (as you make) simply the JasperReport core makes a difference between the value of employee hours and the average calculated at this point of report...so for the first one the average is 3... 3-3 =0for the second is 3+6=9 /2=4,5 6-4,5=1,5and so on...give us feedback...________________________________________if it works... give me KARMA points please! : ) _________________________________________listening: Stereolab- Emperor Tomato KetchPost Edited by slow at 08/18/2010 09:59 Link to comment Share on other sites More sharing options...
juser73 Posted August 18, 2010 Author Share Posted August 18, 2010 That did it! Thanks for the help, I did exactly what you said and it fixed the problem. Thanks again :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now