# Calculate sum,maxi and mini for the multiple columns in excel sheet?

Hi all,
I need to calculate sum,maximum and minimum for all the columns in the attached excel sheet. Can you please help me out with this ASAP.

Hi
To get the sum
dt.AsEnumerable().Sum(Function(x) If(IsNumeric(x(“Column2”).ToString.Trim),CDbl(x(“Column2”).ToString.Trim),0))

To get the Max
dt.AsEnumerable().Max(Function(x) If(IsNumeric(x(“Column2”).ToString.Trim),CDbl(x(“Column2”).ToString.Trim),0))

To get the Min
dt.AsEnumerable().Min(Function(x) If(IsNumeric(x(“Column2”).ToString.Trim),CDbl(x(“Column2”).ToString.Trim),0))

Cheers @Manideep2701

I have tried using assign activty (sum= dt.AsEnumerable.Sum(Function(x) If(IsNumeric(x(“Column2”).ToString.Trim),CDbl(x(“Column2”).ToString.Trim),0)))
Variable type of sum is Decimal.

still it is not working.

I have attached the error below

can you please suggest me on this ASAP.

thank you.

1 Like

Hey
Sorry for the delayed response buddy
Fine
Is AsEnumerable() coming once after typing dt.

If that method is not coming then we need to check once the assembly reference and add if it’s not there

Cheers @Manideep2701

AsEnumerable() is working but Sum(or Max or Min) is not coming after the ‘AsEnumerable().’

Try out this method in Assign,
DataType as Double

dt.AsEnumerable().Sum(Function(x As DataRow) CDbl(x(“Open”).ToString.Trim))

“Open” is column Name
@cheers

@Shiva_Raj @Palaniyappan
The Scenario here is when i’m trying to put the code in the field the function ".sum(Func… " is not reflecting after the expression ‘dt.AsEnumerable()’. This is happening only in my desktop and its working completly fine in my colleagues desktop and also in one of the forum member’s desktop. I have uninstalled the studio and re-installed too.

When your system looks good try the attached. ExcelSeq.xaml (14.1 KB)

Its based on the same logic that is given in the above comments however additional logic to get the required results

2 Likes

just pay attention to your quotes… delete them and type it again, dont copy paste…

1 Like