web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Only add unique values...
Power Apps
Unanswered

Only add unique values to a collection through a Gallery using Collect All.Items logic

(0) ShareShare
ReportReport
Posted on by 34

Hi Community!

 

I am facing an issue related to the use of a Select All checkbox to add all items in a Gallery to my collection. The collection is based on a couple of slicers I have, and I would like this Select All checkbox to add all the current items in the Gallery to my collection. 

 

The problem is however that the Select All box currently adds all items in the Gallery, despite the current selection already made and the items that are already present in the collection. This means that if an item is already selected or present in the collection, it is duplicated in the collection.

 

I would like to avoid this by building in the logic that only the items are added which arent already in the collection. Do anyone have any tips on how to achieve this? Thanks for the help in advance!

 

Overview

jeroen1290_0-1718716971486.png

 

Select All OnCheck

UpdateContext({CheckCheckbox:true});ForAll(Collect(SelectedBudgetOwners,GalleryBudgetOwners.AllItems),ThisRecord)
 
Select All OnUncheck (this removes all items in the gallery)
Remove(SelectedBudgetOwners, GalleryBudgetOwners.AllItems); UpdateContext({CheckCheckbox:false});
 
CheckBox Default
CheckCheckbox
 
CheckBox OnCheck
Collect(SelectedBudgetOwners, ThisItem)
 
CheckBox OnUncheck
Remove(SelectedBudgetOwners, ThisItem)
 
Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @jeroen1290 ,

     

    Please try to add an If condition in your formula.

    Sample:

    UpdateContext({CheckCheckbox:true});
    ForAll(GalleryBudgetOwners.AllItems) As temp, If(temp.<column name>) in SelectedBudgetOwners.<column name>,Blank(),Collect(SelectedBudgetOwners,temp))

     

    Best Regards,

    Wearsky

  • jeroen1290 Profile Picture
    34 on at

    Hi @v-xiaochen-msft,

     

    Thanks for the response! However, I do not fully understand what you want me to full in. I tried the following, but the "as temp" part doesnt work as "Invalid number of arguments, received 1, expected 2". 

     

    UpdateContext({CheckCheckbox:true});
    ForAll(GalleryBudgetOwners.AllItems) As temp, If(temp.CostObjectLocalBudgetOwner) in SelectedBudgetOwners.CostObjectLocalBudgetOwner,Blank(),Collect(SelectedBudgetOwners,temp))
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @jeroen1290 ,

     

    Sorry, I typed extra parentheses.

    Please try this

    UpdateContext({CheckCheckbox:true});
    ForAll(GalleryBudgetOwners.AllItems As temp, If(temp.<column name> in SelectedBudgetOwners.<column name>,Blank(),Collect(SelectedBudgetOwners,temp))

     

    Best Regards,

    Wearsky

  • jeroen1290 Profile Picture
    34 on at

    Hi @v-xiaochen-msft

     

    Thanks! It seems to work now. The only thing is that even though only the unique values are added when I hit add, only these are then remove when i deselect all. However, when I deselect all, I want all the variables in the galary to be remove from the collection.

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @jeroen1290 ,

     

    Please try this in onuncheck property

    ForAll(GalleryBudgetOwners.AllItems As temp, Remove(SelectedBudgetOwners, LookUp(SelectedBudgetOwners,<Column Name>=temp.<Column Name>)));UpdateContext({CheckCheckbox:false});

     

    Best Regards,

    Wearsky

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard