cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Change colour of icon if a value matches between selected item in gallery, and Collection items

I have a gallery (Gallery1) and a Collection (Collection1).

 

Gallery1 has a list of users with email addresses

 

Collection1 is a table of users who are members of a Group, and each includes their email. 

 

I want to change the colour of an icon, if the selected user in Gallery1 matches an entry in Collection1.

 

I've tried this, but clearly it doesn't work!

 

If(Collection1,Member.email = Gallery1.Selected.Email,Green,Red)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

It looks like your collection has the following structure:

 

Collection1: [{

    Email: [{

        userPrincipalName: ""

    }]

}]

 

You'll want this collection to be flatter, like so:

 

Collection1: [{

    userPrincipalName: ""

}]

 

You should be able to change your function to this, to achieve the desired structure:

ClearCollect(Collection1, AzureAD.GetGroupMembers("6ac59a2e-*****-4f18-******-0f9b52cba5af").value.userPrincipalName)

Lastly, you can update your filter function to:

If(email in Collection1.userPrincipalName, Red, Green)

Let me know if this doesn't work.

View solution in original post

7 REPLIES 7
Highlighted
Power Apps
Power Apps

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

To test if a user is in the collection,  you'll want to use the "in" operator like so,

 

If(email in Collection1.email, Red, Green)

 

 

Highlighted
Super User
Super User

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

The above solution should work fine for you. If you want a complete overview of conditional formatting in PowerApps check out the linked video. I show some different things I do in this context to help you learn the basics. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
Highlighted
Helper I
Helper I

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

Hi both, thanks for the rapid responses. Unfortunately that doesn't seem to work in my app.

 

I have tried this:

 

If('Gallery 1'.Selected.Email  in Collection1.Email,Green,Red)

"Cannot automatically convert this text value into a table" (It highlights the first .Email as the culprit.

Highlighted
Power Apps
Power Apps

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

Can you confirm that Collection.Email is text? You might be receiving this error if the data in Collection1.Email is a nested table. If possible, could you send a snapshot of your collections table with anonymized emails?

Highlighted
Helper I
Helper I

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

I create the Collection using this:

 

ClearCollect(Collection1, {Email: AzureAD.GetGroupMembers("6ac59a2e-*****-4f18-******-0f9b52cba5af").value.userPrincipalName})

Collection.PNG

 

 

Highlighted
Power Apps
Power Apps

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

It looks like your collection has the following structure:

 

Collection1: [{

    Email: [{

        userPrincipalName: ""

    }]

}]

 

You'll want this collection to be flatter, like so:

 

Collection1: [{

    userPrincipalName: ""

}]

 

You should be able to change your function to this, to achieve the desired structure:

ClearCollect(Collection1, AzureAD.GetGroupMembers("6ac59a2e-*****-4f18-******-0f9b52cba5af").value.userPrincipalName)

Lastly, you can update your filter function to:

If(email in Collection1.userPrincipalName, Red, Green)

Let me know if this doesn't work.

View solution in original post

Highlighted
Helper I
Helper I

Re: Change colour of icon if a value matches between selected item in gallery, and Collection items

Perfect - thanks!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,205)