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

Notifications

Announcements

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
    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
    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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard