DataTable Sum Columns

I want to calculate the total horizontally using Linq in the data table.

Ex)
Col1 | Col2 | Sum
100 | 200 | 300

@yekho - Hi Welcome to UiPath Forum. I have attached sum link for your reference. Could please refer the link and clarify your doubts. If you not clarify please let me know.

Happy Learning :slightly_smiling_face:

Hi @yekho

Please use the below method.

row(“Sum”)=(Convert.ToInt32(if(row(“Col1”).Tostring<>“”,row(“Col1”),0))+Convert.ToInt32(if(row(“Col2”).Tostring<>“”,row(“Col2”),0))

Thanks, Happy Automation

For a row WE can do with following

row.ItemArray.Sum(function (x) Convert.ToInt32(“0” & x.toString))

1 Like