Adding Values of column

Hii Guys!!

I have a column with Numeric values. I have to add all the values in the column with each other. But the no of line items in the column is not fixed. It may have more no of line items sometimes. How can I add all the Values? Help me to Solve in this.

Thanks in Advance :slight_smile:
Capture

1 Like

Hi @mohamedalthaf

You can use linq to get the sum.

1 Like

Hi @mohamedalthaf

Please have a look.

Hope this helps to solve.

Thanks.

1 Like

Hi @mohamedalthaf

Kindly refer this

Thanks

1 Like

Hi

Hope the below expression would help you resolve this

It doesn’t rely on number of line items
And can handle any number of rows

  1. Use read range activity and get the datatable dt as output

  2. Then use a assign activity like this

dou_sumvalue = dt.AsEnumerable.Sum(Function(x) If(IsNumeric(x(“Amount”).ToString.Trim),CDbl(x(“Amount”).ToString.Trim),0))

Where dou_sumvalue is a variable of type system.double

For more details on data le functions

Cheers @mohamedalthaf

1 Like

Hi @mohamedalthaf

Try this below expression

(From d in dtData.AsEnumerable Where Not (isNothing(d(Amount)) OrElse String.IsNullorEmpty(d(Amount).toString.Trim)) Select v = CDbl(d(Amount).toString.Trim)).Sum(Function (x) x)

Regards
Gokul

1 Like

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