Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:39:58+00:00 2026-05-23T13:39:58+00:00

I need to make some aggregates using TClientdataset . In SQL these aggregates can

  • 0

I need to make some aggregates using TClientdataset. In SQL these aggregates can be done with script like this :

Select Sum(column1) from table1 where Date_Column < Date_Value

Because I need more speed during a very long process and a very slow network, I want to use in-memory aggregates instead of using sql . My idea is to add an aggregate to the ClientDataset with Expression like this:

Sum(column1)

And make Date_Column index, then filter the clientdataset like this:

myClientdataset.SetRang([value1],[value2]);

I was expecting to see the aggregate result of this range, but, unfortunately the aggregate ignore the range and keep giving the result of all records!

So, my question is: how I can achieve this in TClientdataset? Or, do you have any other idea how to do ranged-aggregates in memory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:39:58+00:00Added an answer on May 23, 2026 at 1:39 pm

    Maybe this link will be helpful: Grouping and Aggregates

    Edit:

    I think i’ve got it, it took me quite time and it was a frustrating experience;)

    I’ve made a sample project.

    First, an aggregate without filtering:

    Aggregate without filtering

    Second, an aggregate after presing a button:

    Aggregate with filtering

    Is this is the effect which you wanted?

    Please note that I was not able to achieve this efect with usage of SetRange(), I’ve used Filter property instead.

    How to achieve:

    1. Create an index on some field, GroupingLevel must be 0.
    2. Setup that index as a property of TClientDataset.IndexName.
    3. Create an aggregate with GroupingLevel = 0 and Expression like SUM(YourFieldName), in my case it was SUM(Population).
    4. In IndexName property write the index which you’ve created.
    5. Setup the aggregate to active in designtime, (setting it up in runtime seemed to not work).

    My code after pressing a button:

      cdsMain.Filter := 'Population <= 100';
      cdsMain.Filtered := True;
      if not VarIsNull(cdsMain.Aggregates[0].Value) then
        lblAggregatedPopulation.Caption := 'Aggregated population: ' + IntToStr(cdsMain.Aggregates[0].Value);
    

    Please note that in Filter you can easly change condition to achieve the same result as for the SetRange. However, I’ve read that SetRange is faster in filtering data.

    Hope it helps:)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make some commits using Git but I would like the timestamp
I need to make some reflective method calls in Java. Those calls will include
I need to make some code to talk to a SOAP web service. Unfortunately
In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically
I need to make a WebCast presentation soon and need to do some whiteboarding
I need to make sure that user can run only one instance of my
I have this code for make some request to my server: function myAjaxCheck(token) {
I have a crystal report file I need make a tiny edit in. It
I need to make an application in .NET CF with different/single forms with a
I need to make an ArrayList of ArrayLists thread safe. I also cannot have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.