Problem on filter data table activity

Hi All,

I meet a problem when using the filter data table activity. I want to filter out the rows that only “AbsoluteDifference” > 2, but my workflow does not work. There is nothing shown on the output folder - validated Excel - sheet 2. I wonder if you can help me with that. I put my xaml and input excel here. Thank you very much!




Question bot.zip (103.1 KB)

Hi,

It’s probably because data in datatable is recognized as string type.
Can you try the following expression?

arrDr = DT_validated.AsEnumerable.Where(Function(r) CDbl(r("AbsoluteDifference").ToString)>=threshold).ToArray()

Then check if arrDr has item using arrDr.Any in Condition property of IF

arrDr.Any

Then

DT_Fil = arrDr.CopyToDataTable()

Else

DT_Fil = DT_validated.Clone()

Regards,


Thank you so much Yoichi,

I meet a new question shown in this image, when I try the first expression, it gives this note which I can’t figure out how to do next. Should I change the variable type to something else?

HI,

Can you try to set DatatRow array type for arrDr at variable panel?

Regards,


Thank you so much, it let me input the expression now.
Another error here is shown in the image. I am confused that if the part “r(“AbsoluteDifference”)” is referring to the column [AbsoluteDifference], if so, the value in this column is already in Double type. What should I do to avoid this error?

Hi,

Probably there is blank cell in AbsoluteDifference column. How do you want to handle it, regarded as 0 or always skip etc?

Regards,

HI,

If we can always skip non-numeric value, the following will work.

DT_validated.AsEnumerable.Where(Function(r) r("AbsoluteDifference").ToString.IsNumeric AndAlso CDbl(r("AbsoluteDifference").ToString)>=threshold).ToArray()

Regards

Thank you again! I really appreciate you helping me, it works right now!

1 Like

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