cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Patron
Post Patron

Values duplicating in Collection

Hi Power Apps Community,

I recently had one of my posts answered where I would like to perform a Search based on the fields in a Collection.

The solution to this was to use the 'AddColumns' function, which did the trick.

The current issue that I am experiencing is that values are being duplicated in my Collection.
Background: I have created three Collections, where two of the Collections are used to be reference by the third Collection. This was done to assist with the amount of data that I am reading. There are two approaches that I have tried, but have been unsuccessful for both.

1st approach:

 

Concurrent(
    ClearCollect(
    CollectionA,
    AddColumns(
        Filter(List, ID < 2000 && Field.Value = First(Split(Office365Users.MyProfile().UserPrincipalName, "@" )).Result),
        "Title", FieldA.Value)
    ),
    ClearCollect(
    CollectionB,
    AddColumns(
        Filter(List, ID < 2000 And ID < 4000 && Field.Value = First(Split(Office365Users.MyProfile().UserPrincipalName, "@" )).Result),
        "Title", FieldA.Value)
));
ClearCollect(CollectionA+B,CollectionA,CollectionB);

 

2nd approach:

 

Concurrent(
    ClearCollect(
    CollectionA,
    Filter(
    AddColumns(
        List, "Title", FieldA.Value),
        (ID < 2000 && Field.Value = First(Split(Office365Users.MyProfile().UserPrincipalName, "@" )).Result))
    ),
    ClearCollect(
    CollectionB,
    Filter(
    AddColumns(
        Field, "Title", FieldA.Value),
        (ID < 2000 And ID < 4000 && Field.Value = First(Split(Office365Users.MyProfile().UserPrincipalName, "@" )).Result))
));
ClearCollect(CollectionA+B,CollectionA,CollectionB);

 

 Based on my testing, I am expecting to get 10 rows of data into my Gallery, but instead I am getting 20 (double the amount). My assumption is that I am referencing the 'AddColumns' twice in the code, but I have been scratching my head with this one.

I hope that I have explained my issue well.

I would really really appreciate any assistance on this.

Thank you in advance.

2 REPLIES 2
Super User III
Super User III

HI @Data_Enthusiast ,

Firstly, ID is not Delegable other than with the = operator, so greater than/less than will not function as expected with your code. I have done a blog on Delegation and you will see one solution under "big collection". Happy to elaborate further if anything suits your requirements.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Hi @WarrenBelz 

Thank you for sharing the content, very insightful.

With regards to my query, the code was running as required when I did not include the 'AddColumns' section. However when this part was added, my records doubled. And idea on how I may potential go about resolving the code above?

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Solution Authors
Top Kudoed Authors
Users online (9,059)