Help with Lazreport lazarus / 13-General ---------------------------------------------------------------------- n05f3r47u · 2008-12-24 14:07 Hello, i hope you can help me with this; my data date           nbill     c_cust  ncust    subtotal       taxes      total 20/12/2008  0001  11111   aaaaa   43.419,00      0,00     43.419,00 21/12/2008  0002  22222   bbbbb   18.200,00      0,00     18.200,00 21/12/2008  0003  11111   aaaaa  101.528,00  14.560,00 16.088,00 My report design (without page header and master header): |master data| ----------------------------------------------------------------- [c_cust] [ncust]  [date] [nbill] [subtotal] [taxes] [total] ----------------------------------------------------------------- |group footer| -----------------------------------------------------------------           [sum(subtotal)][sum(taxes)][sum(total)] ----------------------------------------------------------------- |Report summary| -----------------------------------------------------------------                      [sum(subtotal)][sum(taxes)][sum(total)] ----------------------------------------------------------------- I expect it comes out this way: 11111111      aaaaaaaaa 20/12/2008     00001    43.419,00                   0,00     43.419,00 11111111      aaaaaaaaa 21/12/2008     00003   101.528,00           14.560,00    116.088,00                                144.947,00           14.560,00    165.507,00 22222222      bbbbbbbbb 21/12/2008     00002    18.200,00                   0,00     18.200,00                                 18.200,00                   0,00     18.200,00                               163.147,00             14.560,00   177.707,00 But... it comes out this way: 11111111      aaaaaaaaa 20/12/2008     00001    43.419,00                   0,00     49.419,00 11111111      aaaaaaaaa 21/12/2008     00003   101.528,00           14.560,00    116.088,00 22222222      bbbbbbbbb 21/12/2008     00002    18.200,00                   0,00     18.200,00                                163.17,00            14.560,00    177.707,00 Is this my mistake? what i can do? what I want is to show subtotal, taxes and total for each customer in my database. Thanks ---------------------------------------------------------------------- jesusr · 2008-12-30 18:47 there are some things in this issue I will try to clarify: 1. You are using a Group Footer band, but a Group Header band is not in your band's layout. A Group Footer band has group condition that is needed to create groups of records, in your case the condition will be simply [DataSet."c_cust"]. 2. In order to LazReport work with groups correctly, data needs to be sorted by key fields, in your case be sure to use some index (or make your query should return sorted data set) by c_cust, this means that data used by LazReport  need to be like this: date           nbill     c_cust  ncust    subtotal       taxes      total 20/12/2008  0001  11111   aaaaa   43.419,00      0,00     43.419,00 21/12/2008  0003  11111   aaaaa  101.528,00  14.560,00 16.088,00 21/12/2008  0002  22222   bbbbb   18.200,00      0,00     18.200,00 with this in mind, I would expect to get a report like this: 11111      aaaaa 20/12/2008     00001    43.419,00                   0,00     43.419,00 21/12/2008     00003   101.528,00           14.560,00    116.088,00                                144.947,00           14.560,00    165.507,00 22222      bbbbb 21/12/2008     00002    18.200,00                   0,00     18.200,00                                 18.200,00                   0,00     18.200,00                               163.147,00             14.560,00   177.707,00 Note that header of second record on cust 11111 is now gone, this looks much similar to what your are expecting. 3. Aggregate functions currently require a second argument of data band name to work correctly. In this case expressions to get the sum would look like this: [sum([DataSet."taxes"], MasterData1)] (that is assuming Master Data band is named MasterData1). This last point was preventing me to write a reply before, the second argument was previously optional but it become required after I found reports with grouped records and aggregate functions were broken in patch http://svn.freepascal.org/cgi- bin/viewvc.cgi?view=rev&root=lazarus&revision=14234 , now I think this second argument should not be necessary because it makes using aggregate functions more difficult, and I want to revert that patch (and my fixes after that). At the moment using second argument reference to data band will continue to be supported even if I revert the patch we are talking about Another way to do reports in an independent way of such patches is to use variables that reference the fileds in dataset, for example: [varTaxes] is a variable that takes value from Dataset."Taxes" then using aggregate function [SUM([VarTaxes])] should work fine, note that no need to specify data band reference. ---------------------------------------------------------------------- n05f3r47u · 2009-01-10 18:14 My Friend Jesus; you saved my life. Thanks. It was my mistake . It was a misunderstanding using the component. I really appreciate your help. Thanks