Multiple Assign: Can not assign 'Packing_Operations.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Payroll Hours”).ToString.Trim) ).ToString' to 'Sum_P'

Hi All,

I’ve been searching everywhere for an answer, but still no luck.

I’m currently fixing an RPA that was done by my predecessor and it’s currently installed on my colleague’s laptop. It was built with Legacy. Now my colleague is due on switching to a new laptop and I’m currently helping migrating that. But every time I try to run with Debug, this error pop ups:

Multiple Assign: Can not assign ‘Packing_Operations.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Payroll Hours”).ToString.Trim) ).ToString’ to ‘Sum_P’.

The process is roughly like this:
Assign CSV file > Read CSV > Do manipulation with Filter Data Table activity > Multi Assign to each variable. Here’s the screenshot of one of the variables:

Please if anyone can enlighten me on this topic, highly appreciate it! I’ve tried everything that I found on the web, but no luck.

Sum_P Datatype is String?

To continue with all other checks:

  • we assume that the DataType are correct as Packaging_Operations is a DataTable
  • ensure all Doublequotes are of type " and not the inverted ones
  • Also often encountered. During a migration a valid statement is doing trouble. Delete it from the assign and type it again

Packing_Operations.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Payroll Hours”).ToString.Trim) ).ToString

That .ToString is trying to convert an enumerable to String. I think you need to remove that and make Sum_P an IEnumerable(of Double)

Then Sum_P(0).ToString will give you the value.

You could do it all together…

Packing_Operations.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Payroll Hours”).ToString.Trim))(0).ToString

Sum operator is returning the corresponding single <T>

1 Like

Oh that’s right, I missed that the Sum is a method of IEnumerable and not something happening within the Function.

Yes, SUM_P is String

  • Yes, correct. Packagin_Operations is defined as DT
  • Doublequotes are also used, not the single inverted ones
  • Thanks for this. This was actually the correct solution - I redefined and retyped my Multiple Assign activity. The RPA is running smoothly.

Appreciate the help!

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