filtering aggregate fields

Please discuss general Delphi programming topics here.

filtering aggregate fields

Postby KylieR » September 25th, 2009, 1:18 am

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.
KylieR
Member
Member
 
Posts: 3
Joined: September 25th, 2009, 1:13 am

Re: filtering aggregate fields

Postby KylieR » September 28th, 2009, 1:42 am

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 :)
KylieR
Member
Member
 
Posts: 3
Joined: September 25th, 2009, 1:13 am

Re: filtering aggregate fields

Postby Kambiz » September 28th, 2009, 6:55 am

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: filtering aggregate fields

Postby KylieR » September 30th, 2009, 1:03 am

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.
KylieR
Member
Member
 
Posts: 3
Joined: September 25th, 2009, 1:13 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 8 guests

cron