LazReport Running Total Field lazarus / 31-LCL ---------------------------------------------------------------------- r_1gm · 2012-06-08 18:23 Hi, Anybody know about Running Total Field in LazReport ? Best Regards, r_1gm ---------------------------------------------------------------------- exdatis · 2012-06-09 06:57 You can use Sum(expression), and band summary. Regards. ---------------------------------------------------------------------- r_1gm · 2012-06-09 12:40 hi exdatis, i already try your suggestion, but i cannot get result that i expect. for example i had, number      total 2                2 5                7 8                15 also we can set initial value for total. with your suggestion i just get 15 for each row. sorry for my bad english ---------------------------------------------------------------------- r_1gm · 2012-06-15 03:25 Hi all, Anybody know about running totals feature implementation(0017198) progress ? ---------------------------------------------------------------------- exdatis · 2012-06-15 05:45 That's not total! That's the progress, shrinkage values. In my opinion, simple solution is: in DBDataSet you can put calculated field, and on Calc event: procedure TYourClass.DataSetCalc..(...); var   my_var : Double = 0;//or integer begin   my_var:= my_var + some_value;//progress of my_var   calc_field.AsFloat:= my_var;//current value of my_var end; Now, you can put calculated field in your report. Regards. p.s. Maybe you need to reset calc_field value, to prevent double calculation, before print( my_var = 0).        (Sorry, I'm late, I have not seen your post of  June 9) ---------------------------------------------------------------------- taazz · 2012-06-15 09:00 LazReport is based on the FreeReport for delphi components which has evolved to fastReport commercial suite. You should try to get the documentation for one of the above suites and read upon it. In short and as far as I can remember, I haven't used those components for more than 5 years, You should create a custom expresion Variable and write code in its value, something like this VariableName := VariableName +[LinkedIndatasetName."FieldWithData"]. This will take care of the running total calculations I dont remember where you should write code to initialize the value to 0 or how this can be accomplished within lazreport it self. You will have to look it up on the documentation of freeReport or FastReport your self. Edit: By the way you are correct the term for this is "running total" because it has different value on each and depends heavily on the order the result set is returned it is called "running total" Regards. ---------------------------------------------------------------------- r_1gm · 2012-06-15 12:49 @exdatis ups... sorry great, i will try, thank you very much exdatis. no problem i already very grateful you are replying @taazz i will check the documentation, but AFAIK(if i not wrong) FastReport already implement this feature and LazReport not yet implementing this feature also the implementation also maybe different, but i will check it again. ---------------------------------------------------------------------- taazz · 2012-06-15 15:49 OK I found some time to play around with LazReport. Here is what I came up with. 01 ) make sure you have a report with a master data band connected to a dataset 02 ) place a text inside that band and double click to open its editor. 03 ) on the editor check the script option on the top left. 04 ) on the script window paste the following code. Code: [Select]IF [Line#] = 1 then RunTotal := [Dbf1."MTH_NO"] else RunTotal := RunTotal +[Dbf1."MTH_NO"]; of-course you need to replace [dbf1."MTH_NO"] with your field, the one you want a running total. 05 ) Press OK to save the changes. 06 ) Press Preview to create the variable and close it. 07 ) reopen the editor by double clicking on the text object 08 ) press the "Variable" button. 09 ) select the fr variables category on the drop down combo. 10 ) double click the RunTotal variable to be place on Memo. 11 ) press OK and then press Preview. You should now have a running total in your band. Edit: Corrected some typing errors. ---------------------------------------------------------------------- r_1gm · 2012-06-17 05:39 @taazz great, thank you taazz.