How to group by in data table when there are a lot of columns?

Here is my requirement

image

All I want to do is group by

I used a method but it is taking a lot of assign activity which I can’t use since there are like 100 fields that I have to group

Please suggest the best way to do this

Hi,
Use the balareva.datatable.activities by @balupad14. In that you have an activity of group by aggregation, just specify the column which you want to group by and the column which you want to aggregate. You can achieve this easily. :slight_smile:

Regards,
Vishal

1 Like

Any other ideas? @Palaniyappan bro

yah as @vishal.kp that would work for sure

or do you want to use linq query, but the above one is easier
Cheers @cybzom

2 Likes

I will try and let u know na

2 Likes

sure
Cheers @cybzom

3 Likes

@Palaniyappan na I can’t group by multiple columns na

Kindly check the flow if you are available Main.xaml (4.8 KB)

What’s the other way? using linq?

@Palaniyappan na

I’m trying to use this linq

(From row In DT.AsEnumerable() Group row By INV =New With { Key .INVNum = row.Item(“PAYGROUP NAME”)} Into INVGroup = Group Select New With {.INVNumber = INV.INVNum, .Sum=INVGroup.Sum(Function® Double.Parse(r.Item(“NET PAY”).ToString()))}).CopyToDataTable

but it’s showing an error like character is not valid

pls review

I can use that activity itself but I want to group by multiple cols na like there are 70+ cols I want the sum of all of them

Maybe this will help you?
https://sensibledev.com/linq-group-by-multiple-columns/

4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.