Find common values in two Power Apps collections

Find matching values in two Power Apps collections

 

Use the formula below to compare two collections and place common values in a new collection.

 

//create collections
ClearCollect(colAnimals_1,["Dog","Cat","Kiwi","Kangaroo","Axolotl","Bear"]);
ClearCollect(colAnimals_2,["Dog","Weta","Cat","Kea","Bear","Koala"]);

//get matches stored in a Collection
ClearCollect(
    colAnimals_Result,
        ShowColumns(
            Filter(
                AddColumns(
                   colAnimals_1,
                  "MatchFound",  
                If(!IsBlank(LookUp(colAnimals_2,Value=colAnimals_1[@Value])),true,false)
            ),
           MatchFound=true),
       "Value")
);

The resultant collection colAnimalsResult will contain: Dog, Cat, Bear