Power Apps - Create Unique List of Collection

I have a collection called as TestCol and it looks like this.

Name      ID      ToAddress                                                        Status
Abc       123     [email protected],[email protected],[email protected]        A        
Def       234     [email protected],[email protected]                                A
Ghi       567     [email protected],[email protected]                              B

I want to create a new collection Called as UniqueToAddress like,

ToAddressUnique
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

It can be seen that [email protected] is repeated multiple times inside the ToAddress and it appears only once on ToAddressUnique Collection. How Can I do this ?

Upvotes: 2

Views: 1755

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87293

You can use the following expression to generate a list of unique addresses:

Distinct(
    Split(
        Concat(TestCol, ToAddress, ","),
        ","),
    Result)

The idea is to first concatenate (using the Concat function) all the addresses in your collection, then split the long string (using the Split function), and finally take only the unique addresses using the Distinct function to get what you need.

Hope this helps!

Upvotes: 2

Related Questions