Loop through Array, Then if statements between through two data table

Hi,

I have two arrays:

I want to loop through the larger array with 20 items in it and see which one of those items match with the smaller array that has 5 items. So my desired output would be 5 match and 15 no match.

@RPA_Path

Try below expression two find matching values between two arrays.

       arrMatch = arrMonthDates.Intersect(arrDataDates)

@RPA_Path

Try below expression.

        arrMatch = arrMonthDates.Intersect(arrDataDates).ToArray

@RPA_Path

Hope arrMonthDates and arrDataDates variables of type Array of String.

Same error as above.

And they both are system array variable

Also, I should note that the 2nd array with 5 items is from a excel data table which is converted into an array

@RPA_Path

I tried the same expression from my end and can’t see any error. Please find the attached screenshot for your reference.

@RPA_Path

It should be of type System.String[] but not System.Array.

I switched and it worked. is there any way I can log the items that didn’t match also?

1 Like

@RPA_Path

Yes its possible. Please try below expression.

                            arrNoMatch = arrMonthDates.Except(arrDataDates).ToArray

Thank you!

1 Like

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