How to filter a list of collection in one column

hello community. i have one list of collection with numbers for example (111, 123 , 666 , 777) and i want to filter this numbers in a specific column in data table to get those rows with this numbers. in this column may i have a multiple times these numbers but i want all the rows. at the biggening i put the list in a data table (so now i have 2 data tables) and then i put the activity join and i put firs the table that i want to filter and the other one as a second, i use the type inner and i put the two column as = . but i didt get the results

Hi @nkaizer

Here’s the simple Assign expressions which you can use to achieve the expected result

colName = “Code”

nums = {111, 123, 666, 777}

filterExpr = String.Join(" OR ", nums.Select(Function(n) $“Convert([{colName}],‘System.Int32’) = {n}”))

filteredRows = dtData.Select(filterExpr)

dtFiltered = If(filteredRows.Any(), filteredRows.CopyToDataTable(),dtData.Clone())

Please do check and let me know

Happy Automation

FOR THE ASIGN fILTERESrOWS I HAVE THIS ERROR : Argument ‘Value’: BC30311: Value of type ‘DataRow()’ cannot be converted to ‘String’. The selected value is incompatible with the property type.
AND FOR THE LAST ASSIGN this error Argument ‘Value’: BC30456: ‘CopyToDataTable’ is not a member of ‘String’.

@nkaizer

Please modify the 2nd Assign

nums = New Integer(){111,123,666,777}

Also Make sure a filteredRows is of Type System.Data.DataRow

it runs but they give me all the rows instead of the specific from the list

@nkaizer

Can you please share the screenshot ?

now its ok thank you very much,!!

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