Hi everyone,
Can you please let me know how to add each row values, expected output is highlighted in below screenshot
Thank you in advance
Hi everyone,
Can you please let me know how to add each row values, expected output is highlighted in below screenshot
Thank you in advance
Hi @Suma1993
You have used the vb code in the Invoke code activity in the above post right, Remove that code in Invoke code activity give the below one,
' Initialize the output DataTable
Dim outputDt As New DataTable
outputDt.Columns.Add("Date")
' Get distinct Invoice Dates to use as columns
Dim invoiceDates = inputDt.AsEnumerable().Select(Function(row) row("Invoice Date").ToString()).Distinct().ToList()
' Add columns for each distinct Invoice Date
For Each dateStr In invoiceDates
outputDt.Columns.Add(dateStr)
Next
' Add Total column
outputDt.Columns.Add("Total", GetType(Integer))
' Get distinct Dates to use as rows
Dim dates = inputDt.AsEnumerable().Select(Function(row) row("Date").ToString()).Distinct().ToList()
' Populate the output DataTable
For Each dateStr In dates
Dim newRow As DataRow = outputDt.NewRow()
newRow("Date") = dateStr
Dim totalRowAmount As Integer = 0
For Each invoiceDate In invoiceDates
Dim totalAmount = inputDt.AsEnumerable().
Where(Function(row) row("Date").ToString() = dateStr AndAlso row("Invoice Date").ToString() = invoiceDate).
Sum(Function(row) Convert.ToInt32(row("Net Amount")))
If totalAmount > 0 Then
newRow(invoiceDate) = totalAmount
totalRowAmount += totalAmount
End If
Next
newRow("Total") = totalRowAmount
outputDt.Rows.Add(newRow)
Next
' Assign the result to the output argument
Output_dt = outputDt
→ The Arguments and flow is same.
Check the below excel output for better understanding,

Hope it helps!!
Hi @mkankatala , Thank you so much, its working as expected.
Use “for each excel row”
Select Range,
Add “Write Cell”
In What to Write: “CurrentRow(0)+CurrentRow(1)+CurrentRow(2)”
For Where to Write just select first cell of Total Column and select Auto Increment Row
Hope this helped you ![]()
It’s my pleasure… @Suma1993
Happy Automation!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.