How to get sum of the data based on week which is dynamic

Hello All,

Can any one please let me know how can i get the sum of the data which is seperated by week wise .
And every week the data may or may not change.

Example:image
Thanks in advance

Padmini

@chandrashekar_padmin

Is this an Excel or Datatable ?

cheers :smiley:

Happy learning :smiley:

1 Like

Hello,

It is excel data

1 Like

@chandrashekar_padmin

Hmmm what exactly do you want to do in your xaml.Based on my perspective you can get the sum value of column in excel using formula or just click the sum functions in excel ? But if you want to get the value using uipath is doable.
Just asking :smiley:

cheers :smiley:

Happy leaning :smiley:

1 Like

Hi,

Can i get the sum value for each week as u can see i have data seperated week by week using uipath?

And, this data will not be same every week. So for dynamic data how can we do sum?

Regards

Padmini

1 Like

@chandrashekar_padmin
Is that a static position of sum,Because if we have a static positon we can set the range of uipath and get the sum every week.

cheers :smiley:

Happy learning :smiley:

1 Like

No it is not static, it is dynamic.
If it is static we could have done using sum function itself.

1 Like

@chandrashekar_padmin

Can you send me your excel file I will try it tomorrow. Once done I will notify you.

cheers :smiley:

Happy learning :smiley:

3 Likes

Not sure if I understand your problem correctly but could you not loop trough the datatabel (excelData) and do the sum yourself in UIPath?

And then write this back to excel?

1 Like

Hello @pattyricarte ,

Yea sure … i have attached the excel to you.
Please let me know if it works.
Thanks,
PadminiTest.xlsx (10.1 KB)

1 Like

Hello,

Should i do this in excel application scope.
I will try this and let you know if it works.

Thanks,
Padmini

1 Like

Yes you can do this in the excel application scope

connect the scope to the correct workbook
use a readRange activity to get the data in a dataTable variable

then use the code shown above

and after that use writeRange to write the data back to your excel sheet

1 Like

Hello,

I am not able to use If condition for this . Please find the error.

Thanks in advance.

1 Like

Hi @chandrashekar_padmin,

If you would like to iterate through each row in a datatable, please use “For Each Row” activity instead of “For Each” activity, Otherwise set the type argument as “System.Data.Datarow” in your “For Each” activity.


Warm regards,
Nimin

1 Like

Hello,

I tried the code but it did not work as expected.It says input is not in correct format.
Please let me know if i need to make any changes to xaml.

Thanks,
PadminiTest.xaml (10.0 KB)

Hi @chandrashekar_padmin,

The issue may be with your values in the price column. It contains special characters like "$" and"," .
Please change your sum calculation to ,
sum = sum +Int32.Parse(("price").ToString.Replace("$","").Replace(",",""))
and try again. :slightly_smiling_face:

Warm Regards,
Nimin

Same issue

Hi @chandrashekar_padmin ,

Could you please upload your sample input excel file?

Hi chandrashekar_padmin,

A few things I noticed when trying your workflow. The sheet name could be something else depending on your excel language (for me I had to change it to blad1 since that is sheet1 in dutch)

second in the sum part in the then clause you have: sum + Int32.parse(“price”)
this should be: sum + Int32.Parse(row(“price”))

And as sugested by nimin, we need to remove the and , to make it work: sum + Int32.Parse(row("price").ToString.Replace("“,”").Replace(",",""))

last, your sum variable is string, change this to Int32 and change the “0” to 0

hope this will solve the issues

also make sure that on the placed I put “price” you put the header name of your price column

Test.xaml (10.5 KB)

1 Like

Thank you so much @tbrinkman