Reputation: 2298
Having 2 lists, I want check which values of List1
are in List2
. I'm trying as below but I get error
List1 = {3,2,8,7,5}
List2 = {1,3,4,2,6,7,9}
= List.Transform(List1, each Text.Contains(List2, _))
Expression.Error: We cannot convert a value of type List to type Text.
Details:
Value=[List]
Type=[Type]
My expected output would be 3,2,7
.
How can I do this?
Upvotes: 0
Views: 83
Reputation: 40204
@horseyride has probably the best answer but using your original logic, you could also write the intersection like this:
List.Select(List1, each List.Contains(List2, _))
This uses Select
instead of Transform
since you are trying to select/filter instead of changing the elements and uses the appropriate List
type instead of Text
for the Contains
part.
Upvotes: 1
Reputation: 21318
See List.Intersect Documentation
Intersect = List.Intersect({List1,List2})
Upvotes: 2