cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BrianHFASPS
Level 8

Prevent duplicates when adding to one collection from another?

I have a list of students. My parents find their student and add them to a list for sign-out, they may have multiple children. The problem is I am trying to prevent them adding the same child more than once. In my master list I have an icon in a gallery that says:

Collect(Roster, ThisItem)

Roster is my collection to process for sign-out. I tried this:

If(IsBlank(LookUp(Roster,'User ID'=ThisItem.'User ID')),Collect(Roster, ThisItem))

This always returns the first (and usually only) record no matter what so it blocks adding a second student. I am trying to check if the record to be added is already in list and if so prevent duplicating? Any suggestions?

4 REPLIES 4
cwebb365
Level 10

Re: Prevent duplicates when adding to one collection from another?

where are you putting this if statement? If the item isn’t created yet then I don’t think this item is going to return anything. You should be trying to compare it to the text value of the user if control?
BrianHFASPS
Level 8

Re: Prevent duplicates when adding to one collection from another?

I have a gallery for the from collection and there is an icon in each item and that code is in the OnSelect section. The problem is as soon as I add one item the LookUp always returns true. It seems like the LookUp is returning something even when it shouldn't be?

datamaster
Level 8

Re: Prevent duplicates when adding to one collection from another?

@BrianHFASPS  as @cwebb365  mentioned what's probably happeing is the ID of the collection you are in has an ID that matches the ID of the Roster but not the same person. You should try some other unique value such as If(IsBlank(Lookup(Roster,'First Name' = ThisItem." First Name' && 'Last Name'=ThisItem.'Last Name' && DOB=ThisItem.DOB)),Collect(Roster, ThisItem))

 

 

------------------------------------------------------------------------------OfficePowerUser.com------------------------------------------------------------------------ 
If this post helps answer your question, please click on “Accept as Solution” to help other members. If you thought this post was helpful, please give it a Thumbs Up. 

 

BrianHFASPS
Level 8

Re: Prevent duplicates when adding to one collection from another?

The User ID field is my unique identifier and key in SQL table the colleciton is built from. The problem seems to be the statement doesn't see a blank response from lookup if the roster collection has anything in it? It is like the lookup is returning some non-blank table?

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,492)