Sum from Datatable

Hi,
I’ve a DT as follows

Company Code Cost Center Profit Center Currency GL Account Debit Amount Credit Amount Text Posting Key Total Amount
XYZ01 ABCDDD01 USD 1234567 8916.94 ACC. BASE SALARY 10 8916.94
XYZ02 ABCDDD02 USD 1234567 5468.68 ACC. BASE SALARY 10 5468.68
XYZ03 ABCDDD03 USD 1234567 5180.12 ACC. BASE SALARY 10 5180.12
XYZ04 ABCDDD04 USD 1234567 4858.16 ACC. BASE SALARY 10 4858.16
XYZ05 ABCDDD05 USD 1234567 4302.32 ACC. BASE SALARY 10 4302.32
XYZ06 ABCDDD06 USD 1234567 4217.98 ACC. BASE SALARY 10 4217.98
XYZ07 ABCDDD07 USD 1234567 3604.52 ACC. BASE SALARY 10 3604.52
XYZ08 ABCDDD08 USD 1234567 3190.7 ACC. BASE SALARY 10 3190.7
XYZ09 ABCDDD09 USD 1234567 2490.66 ACC. BASE SALARY 10 2490.66
XYZ10 ABCDDD10 USD 1234567 2394.64 ACC. BASE SALARY 10 2394.64
XYZ11 ABCDDD11 USD 1234567 2290.9 ACC. BASE SALARY 10 2290.9
XYZ12 ABCDDD12 USD 1234567 2262.98 ACC. BASE SALARY 10 2262.98
XYZ13 ABCDDD13 USD 1234567 1871.18 ACC. BASE SALARY 10 1871.18

can I get total for Debit and Credit, I want to validate the total should equal.
Please help.

Hi @Sanjoy_Kr_Singharoy
I think it’s work (by assign activity). It standard vb expression.

Rgds,
J,

Use ‘For Each Row’ activity to iterate through each row. Then add an if activity and the condition as (CInt(row(“Debit Amount”))+CInt(row(“Credit Amount”))) = CInt(row(Total Amount)).
Hope this helps.

Use assign activity.

dataTable.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)("Debit Amount"))
dataTable.AsEnumerable().Sum(Function(row) row.Field(Of Decimal)("Credit Amount"))
1 Like

I assigned the variable as Int32, string but still getting the following error

change it to
row.Field(Of integer)

Refer this Post For Alternate Approaches

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