How to add data in Column and get Total Count

Hi Everyone,

I need to add data, in Column G and get the total count

image
It won’t be 3 rows, it will increase or decrease.
Please, help out

Thank u

2 Likes

Hi @sudhasagar

Use this query

int SumValue=Convert.ToInt32(dt.AsEnumerable().Sum(Function(row) row(“NET AMOUNT”)))

Thanks
Ashwin S

Hi
Hope this expression would help you resolve this

stroutput = dt.AsEnumerable().Sum(Function(a) Convert.ToDouble(a.Field(of String)(“yourcolumnname”).ToString)).ToString

Cheers @sudhasagar

image
Its showing error

1 Like

Try with Convert.ToDouble buddy
And make sure we don’t have any special characters like space or minus symbol before the value of the column
stroutput = dt.AsEnumerable().Sum(Function(a) Convert.ToDouble(a.Field(of String)(“yourcolumnname”).ToString.Trim)).ToString

Cheers @sudhasagar

3 Likes

I Found the Solution, Using While Loop

Thanks for support

Thank you,
It Worked
Compared to my one, ur one is easy and i’m going to use ur function.

Cheers @sudhasagar

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