dosmo Posted June 3, 2011 Share Posted June 3, 2011 hi,i want my report to do this:date item1 item2 total03.01 1 1 602.01 1 1 401.01 1 1 2 so i need a total column that sums up 2 other columns upwardsthank you for your help Link to comment Share on other sites More sharing options...
despec Posted June 3, 2011 Share Posted June 3, 2011 I would imagine that something like this is best accomplished in the SQL query itself...Something like: select date_field, sum(item1) as item_1_total, sum(item2) as item_2_total, sum(item1+ item2) over (partition by date_field desc) as running_totalfrom your_databaseorder by date_field desc Hopefully this will give you the basic idea...David Link to comment Share on other sites More sharing options...
dosmo Posted June 7, 2011 Author Share Posted June 7, 2011 hello davidthank you for your responsebut i need a solution that takes the total from the previous day and adds the items from the current dayyours just gives me total of the whole report Link to comment Share on other sites More sharing options...
dosmo Posted June 8, 2011 Author Share Posted June 8, 2011 OK,I summarised my items in the query and created a variable that had the "total" field as initial expression and "$V{ITEM_COUNT}.subtract($F{ITEM_COUNT} )" as a variable expression. The variable has evaluation time set to "now" and calculation type "nothing".so the problem is that the first item is already subtracted from the total when the report is printed but i want the actual total to show first :( Post Edited by dosmo at 08/06/2011 14:07 Link to comment Share on other sites More sharing options...
despec Posted June 8, 2011 Share Posted June 8, 2011 selectdate_field,sum(item1) as item_1_total,sum(item2) as item_2_total,sum(sum(item1+ item2)) over (order by date_field asc) as running_totalfromyour_databasegroup by date_fieldorder by date_field desc===============================================================Forgot the "group by" in the initial query, and the sum over wasn't formatted correctly...My apologies. I tested this query using data at my office and the output shows the day total, then the running total like so:Date A_Balance Running_Balance==== ======== =============6-1-11 186066 31830245-1-11 192135 29969584-1-11 195705 2804823 .....and so on.... David Post Edited by despec at 06/08/2011 12:41 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