Hello,
I need to update a DT column values for all the DT rows.
I’m working with more than 70k rows, so the for each activity is not the best solution (it takes too long) and I’m working with the DT.columns(“ColumnName”).Expression assign activity.
The rule i’m trying to have is DT.columns(“X”).Expression = “[Column A]+[Column B]”
What i have is that the resulting DT does not have all the column X fields populated (even if column A and B have the field populated).
For a LINQ approach, ensure the prepared dtResult which has column X on the end
(From d in dtData.AsEnumerable
Let cj = d("Column A").toString & d("Column B").toString
Let ra = d.Itemarray.Append(cj).toArray
Select r = dtresult.Rows.Add(ra)).CopyToDataTable
(From d in dtData.AsEnumerable
Let colSet = new String(){"Commodity","Trade_Type","TRANSACTION_TYPE","Calculation_Type","MarketCodeIdx2","CONTROPARTE_CONSUNTIVO","Ptf_Bilancio_Da","Gestore"}
Let jc = String.Join(" ",colSet.Select(Function (x) d(x)))
Let ra = d.Itemarray.Append(ca).toArray
Select r = dtresult.Rows.Add(ra)).CopyToDataTable
i modified your code with my DT as follow:
(From d In DTOrigine.AsEnumerable
Let colSet = New String(){“Commodity”,“Trade_Type”,“TRANSACTION_TYPE”,“Calculation_Type”,“MarketCodeIdx2”,“CONTROPARTE_CONSUNTIVO”,“Ptf_Bilancio_Da”,“Gestore”}
Let jc = String.Join(" ",colSet.Select(Function (x) d(x)))
Let ra = d.Itemarray.Append(jc).toArray
Select r = dtresult.Rows.Add(ra)).CopyToDataTable
Uipath reports:
Assign: Input array is longer than the number of columns in this table.
Have you checked if you have cell with null value(s) where column X is empty?
E.g. the first three rows in the table below have null values:
With the expression "[Dosage]+[Drug]+[PatientID]" in Sum column you get:
If you modify the expression to check for null and replace it with an empty string, you will get:
Expression: "ISNULL([Dosage],'')+ISNULL([Drug],'')+ISNULL([PatientID],'')"