Specified cast is not valid on Assign Activity

I’m using this on an Assign activity

input_dt.AsEnumerable().GroupBy(Function(i) i.Field(Of Double)(“No_Documento”)).Select(Function(g) g.First).CopyToDataTable

But keep getting the “Specified cast is not valid” error.
What should I change?

the issue comes from 1 or more values present in the No_Documento column which are invalid for getting parsed/casted to a Double

e.g.*

  • Blank Values
  • strings in an invalid format like 1.000,25
  • letters…

In a first step we would recommend to inspect and to analyse non parseable values more in detail

Similar it was done here for datetimes:

we can do it with a stetement within the immediate panel

input_dt.AsEnumerable.Where(Function (x) Not Double.TryParse(x("No_Documento").ToString.Trim,nothing)).ToList

The thing is that I’m using the range 1:1000000 because the robot pulls data daily and we don’t have a precise amount of data on the same doc every day.

In that case there’s a lot of blank data.

How can I adapt it to run according to the lenght of the doc

Ok, blanks will cause this

We assume the data comes from Excel and starts at first Cell (A1)

Using read range and set the range box to empty String
grafik

then it will read the data block and you can avoid the read-in of non-filled rows after the last filled row

  • filter out - blank rows
  • handle non parseable Document numbers e.g filterout or set a dummy / default /alternate value

As Your LINQ looks like deduplication of rows related to the document no you can maybe also split the datatable into two sets

  • the set which is processeable - here we do the deduplication
  • the issue set forwarded to a manually resolution