Sum values group by columns

excel
#1

Hi guys,
I have just started work with UIPath and have some issues.
can you please help me to understand how to develop the follow code in UI Path for DataTable:
select client_number, Currency, Start_Date, End_Date, sum(Amount) as sum_amount, sum(Commision) as commision
group by client_number, Currency, Start_Date, End_Date
The excel example is attached.
Thank you very much in advance!
DimaUntitled.xlsx (10.8 KB)

#2

Hi @Stelz,

Refer this

Regards,
Arivu

1 Like
Sum of all Repeated values in Excel
#3

HI @Stelz,
It may help you.

Regards
Balamurugan.S

1 Like
Sum of all Repeated values in Excel
#4

Thank you very much. It works. Sorry for late reply

1 Like
#5

How can you sum the values of a column without using balareva.datatable.activities ?

#6

Hi @Fer
Try below code

DataTableName.Compute("Sum(Amount)", string.Empty);

Regards,
Arivu :slight_smile:

#7

Amount is the name of the column that i am searching values to sum?

#8

Yes “Amount” is column name from the datatable which you want to sum

#9

DataTableName is as System.Data.Datatable
sum = DataTableName.Compute(“Sum(Amount)”, string.Empty) where sum is defined as int32

Returns error

#10

sum= Convert.ToInt32(DataTableName. Compute("SUM(Amount)", string.Empty))

Regards,
Arivu :slight_smile:

#11

Returns this error: Assign : Invalid usage of aggregate function Sum() and Type: Object.

#12

Ok try below code

DataTableName.AsEnumerable.Sum(Function(x) If(IsNumeric(x("Amount").ToString.Trim),CDbl(x("Amount").ToString.Trim),0))

Regards,
Arivu :slight_smile:

1 Like
#13

How do you have declared the variable that is storing the code? Since I’m not getting AsEnumerable

#14

hi fellow, it seems this activity only can group and sum of on colunms, is it works while group multiple columns?