cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
peace2158
Frequent Visitor

How to put preselected checkbox items from gallery into collection?

I have a gallery with checkboxes and some of them are preselected based on a previous input. I need a formula that will go through the gallery and list the selected checkboxes into a collection. Once someone selects/deselects the checkbox it needs to be added/removed from the collection. 

 

I currently have a collect and remove function in the on check and on uncheck section of the checkbox.

 

The data in the checkbox is pulled from a groupby function so there are 3 columns in my collection. 

 

Thank you so much for your help!!

9 REPLIES 9
RandyHayes
Super User
Super User

@peace2158 

You really don't need the collections for any of this.  The Gallery already serves as a collection/table.

 

To get all the checked rows in your Gallery, use the following formula:

   Filter(yourGallery.AllItems, yourCheckBox.Value)

This will return a table of all the checked rows.

No additional OnCheck/OnUncheck or collections needed.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy,

 

The filtering works perfectly thank you!

 

I've run into another problem. I have 3 galleries. Based on the selected of the first gallery it displays items in the second one, and based on the second one, it displays the items in the third one. 

 

My items formula for the second gallery is: GroupBy(Filter('Items', Branch in Filter(galDirectorate_2.AllItems, cbDirectorate_2.Value).Branch), "Directorate0", "Branch","GroupedDirectorate")

 

And my default is : If(cbDirectorate_3.Text exactin LookUp('BIA Data', ID = varIDedit).'Upstream Directorate', true, false)

 

When I edit past data that i already imputed, all of the galleries work. It only doesnt work when im filling blank data.

 

Also, I can see all of my items in the preview table but they arent showing up in the gallery.

 

Thank you! let me know if you need more info!

RandyHayes
Super User
Super User

@peace2158 

I got a little lost in the description!  You mention the "default", what is that a default for?

Can you provide a screenshot or something to show what you are seeing/not seeing?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

peace2158_0-1629143905881.png

peace2158_1-1629144333463.png

 

 

Directorate Gallery Items: GroupBy(Filter('BIA Input', Branch in Filter(galDirectorate_2.AllItems, cbDirectorate_2.Value).Branch), "Directorate0", "Branch","GroupedDirectorate")

 

CheckBox for the Directorate Gallery :If(cbDirectorate_3.Text exactin LookUp('BIA Data', ID = varIDedit).UpstreamDirectorate, true, false)

 

The reason I have a default is because I want people to be able to edit what they previously imputed.

 

Thank you!!

 

 

RandyHayes
Super User
Super User

@peace2158 

We're getting there...

Can you clarify for me where galDirectorate_2 is - I am assuming it is the top gallery of checkboxes - but want to be clear.

Also, it seems that varIDedit is relevant to the process - I assume that is just a numeric record ID?

You are also setting the default based on the text property of the checkbox.   So, I assume that cbDirectorate_3 is in the bottom Gallery under the Directorate label - please clarify and if so, what is the Text property of that check box?

 

I THINK that is all the questions I have at the moment.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
peace2158
Frequent Visitor

.

hey lol sorry i really need to work on renaming my items haha. lets restart... i renamed everything so hopefully this helps

 

peace2158_6-1629215292567.png

 

peace2158_7-1629215292514.png

 

peace2158_8-1629215292613.png

 

peace2158_9-1629215292627.png

 

peace2158_10-1629215292886.png

 

peace2158_11-1629215292845.png

 

peace2158_12-1629215292921.png

 

 

and Yes! varIDedit  is the ID of the record that the person is currently editing. 

 

Thank you so so much 

peace2158_13-1629215292337.png

 

 

RandyHayes
Super User
Super User

@peace2158 

Excellent!!  That looks like it has much more detail...unfortunately, I can't see them very well.  They show up small, even if I zoom in on them they just get blurry.  Can you possibly repost those images in a larger format so I can read the formulas?

Tip, if you're on a Windows computer, you can press windowkey-shift-s on the keyboard to bring up the screen clipper.  Highlight the part you want to clip, then simply come back to your post and do a ctrl-v to paste the clip into the post.

If you *were* doing that before, then just post them in larger format.

 

Thanks.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Attached a doc! 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,702)