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 / Get only checked eleme...
Power Apps
Answered

Get only checked elements of a gallery

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello everyone,

 

I have a gallery which associated with an SQL table "Persons", Inside I have a checkbox for each element. How can I get all the checked element of this gallery please ? I'm struggling to find a way.. I used the "concat" function but did not work.

 

Thanks in advance !

Categories:
I have the same question (0)
  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous Try this,

    Clear(colSelectedPersons);
    ForAll(yourGallery.AllItems, 
     If(ThisRecord.yourCheckBox.Value=true, Collect(colSelectedPersons, {PersonID: ThisRecord.PersonID})
    )

    Here we are iterating through the gallery and collecting the PersonID (as an example, you can change it to whatever you have) of the selected Persons.

     

    Hope this helps!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @CNT 

    Thanks for this suggestion I'll try it, but I have a question plz is this a collection you're using to store values ?

    This is my first time working with collections, and I don't understand where does the "colSelectedPersons" come from.. Is it a collection you've created somewhere ? And how do I get the its value that englobes all the selected items of the gallery ?

     

    Thanks !

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous Glad you asked! Yes, Collections are a temporary storage in the App where you can collect all kind of data that you want to use during the lifetime of the App. In my example, Clear(colSelectdPersons) basically creates and clears that collection ready to add values to it. Inside the FollAll we are checking if the checkbox is selected and if so, we are adding it to our collection. Later, you can use the values in this collection to Patch your SQL db.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @CNT , Nice thanks. So where do I need to insert the above formula ? 

    I'm putting it in a Label control in the Text property to test but didn't work..

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous To test it put it in the OnSelect of a button and click on the button and then goto View -> Collections to see the contents of the collection (it will show the first 5 values as a sample),

    CNT_0-1622464342770.png

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @CNT Okey, what if I want to get the content of the collection is there a function that does this ?

    Thanks !

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous You can get the contents of the collection in different ways, For example you could out it in a ForAll loop,

    ForAll(colSelectedPersons, 
     ThisRecord.Value // This will give the value of the current record
    )

     

    If you share some formulas you have and what you want to achieve, we can find a way to use this collection to reach your goal!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @CNT I actually wanna get all the elements (I wonder if "concat" can be used here), for some reason the expressions Clear and Collect, ForAll doesn't work for me.. It tells me the identifier isn't recognized ..

    Any solution please ?

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous This will give you a variable gblSelectedPersons with the concatenated values (separated by semicolon),

    Set(gblSelectedPersons, Concat(colSelectedPersons, ThisRecord.Value, ";"))

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Anonymous If you the solution helped you,

     

    Please remember to give a 👍 and accept the solution as it will help others in the future.

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 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard