Sum of datatable column using C# uipath

how to calculate sum of particular column using UiPath C#

1 Like

Hey @Ram_Gurav1

Please try the below,

dt.AsEnumerable().Select(row => row("SumColumn")).Sum()

Hope this helps.

Thanks
#nK

not work i am using Uipath C#

Hi,

Can you try the following expression?

dt.AsEnumerable().Sum(r=>Double.Parse(r["ColumnName"].ToString()))

Regards,

1 Like

Exception has been thrown by the target of an invocation.

Hi,

Can you share $exceptionDetails at LocalsPanel when exception occurs?

If your data contains non-numeric data including blank, the following will work

dt.AsEnumerable().Where(r=>Double.TryParse(r["Column2"].ToString(),out dummy)).Sum(r=>Double.Parse(r["Column2"].ToString()))

Note: dummy is double type variable

Regards,

Dear Sir,

i am using Uipath C#

because above given formula not working, i need help in Uipath C#

particular column sum

Hi @Ram_Gurav1 ,

Could you Provide us a Screenshot of What is the Error that you face ?

Or if you can Explain as to what is not working it would help us to understand the situation better.

Hi,

In my environment, the above expression works as the following.

Can you share your project as a file?

Regards,


please refer attached image we are getting this error

@Ram_Gurav1 ,

Could you follow the Steps Mentioned in the Post Below to resolve the Issue :

1 Like

hi Sir,

not work :frowning:

hii @Ram_Gurav1

please do below steps

once adding extension in project.json file , save your current project and close the uipath and json file and reopen uipath and check

please check whether you are passing the correct datatable name and column name

if it is not working in assign try using invoke code activity and pass the arguments properly

the expression given by @Yoichi is correct , please cross check from your side

Hi,

Can you try the following steps?

First, can you try to run the following xaml file in your environment?

Sequence.xaml (8.2 KB)

If it works, these remove activities in the above xaml and copy your activities to it, then run.

Regards,

1 Like

LN_Process.xaml (307.2 KB)
Mail_Orders.xaml (13.1 KB)
project.json (1.8 KB)

still not working

given xaml file not work

Hi,

How about the following?

LN_Process.xaml (307.3 KB)

Regards,

project open in VB not in C# , cant find solution

Hi,

Can you try to replace or add the xaml file to your existing C# project, then run?

Regards,

1 Like

thank you its work

1 Like