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 708337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:22:47+00:00 2026-05-14T04:22:47+00:00

Which is the most effective way to sum data in the DataTable by a

  • 0

Which is the most effective way to sum data in the DataTable by a given criteria?

I have the following table:

KEY_1
KEY_2,
VALUE_1,
VALUE_2

Input:

01101, P, 2, 3
01101, F, 1, 1
01101, P, 4, 4
10102, F, 5, 7

Desired output (new DataTable):

01101, P, 6, 7
01101, F, 1, 1
01101, SUM, 7, 8
10102, F, 5, 7
10102, SUM, 5, 7

I need efficient algorithm, because I have 10k rows and 18 columns in a DataTable.

Thank you.

  • 1 1 Answer
  • 1 View
  • 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-14T04:22:47+00:00Added an answer on May 14, 2026 at 4:22 am

    You may want to consider using LINQ – it has a GroupBy operator which may allows you to do this easily with relatively good performance given teh data size you describe.

    If you need a super-optimized implementation, then you may want to create your own intermediate data structure to represent a summed record, store that some kind of dictionary based on the key, and update it as you loop over each record.

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

Sidebar

Related Questions

I have tabled data in which most of the cells are text inputs or
I have 2 ways of adding images to a table and, which is most
Question: What would be the most effective way of doing a nested list which
I have a table which gets data from the database using PHP. The table
I'm just wondering which method is the most effective if I'm literally just wanting
What is the most effective way to systematize a way of logging what changes
I was wondering what the most effective way of preventing people from stealing my
We have a Silverlight app which we wrote which calls a Silverlight-enabled data service.
What is the most cross-browser effective way to style anchor tags without href's? I
I have a table with values in one column which have to be splitted

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.