Page 1 of 1

filtering aggregate fields

PostPosted: September 25th, 2009, 1:18 am
by KylieR
hi guys,

i'm having a problem with a TAggregateField on a filtered dataset. i'm using a simple SUM expression. before applying a filter, my aggregate field looks fine, it gives me the correct sum of all the records in the dataset. when i apply a filter to the dataset, the aggregate field returns the same value, not the filtered amount.

this is an example of how i'm creating my AggregateField.
fld = new TAggregateField(ClientDataSet);
fld->Active = true;
fld->Expression = "SUM(Amount)";
fld->ResultType = ftFloat;
fld->FieldName = "TotalAmount";
fld->DisplayFormat = "0.00";
fld->Alignment = taRightJustify;
fld->Index = DataSet->FieldCount;
fld->DataSet = DataSet;

any ideas why this would be happening??

please help!
K.

Re: filtering aggregate fields

PostPosted: September 28th, 2009, 1:42 am
by KylieR
so no one has any ideas?

fyi - yes I have set the filtered property, the filter works fine on the dataset. only the aggregate field does not get updated. and i dont want to re-open the dataset, i've already got the set of records i want to work with, i just need the aggregate field to re-calculate.


thanks :)

Re: filtering aggregate fields

PostPosted: September 28th, 2009, 6:55 am
by Kambiz
I have never used an aggregate field, but it's obvious that aggregation works on the whole table's records only.

Records filtering is part of VCL dataset component, but actual aggregation is done by a none VCL interface (IDSCursor). The interface has no access or knowledge about the filtered records in the VCL dataset.

Re: filtering aggregate fields

PostPosted: September 30th, 2009, 1:03 am
by KylieR
Hi Kambiz,

Thank you for that. Very much appreciated.

It does look like I will have to write my own aggregation functionality. Would you know of any parsing tools that evaluate aggregation expressions?


Kylie.