cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rob26r
Regular Visitor

Create Collection of Items in Gallery Not Working

I have a simple table that has 3 vendors.

 

Vendor

100

200

300

 

I created a gallery with the vendor number and added a toggle box with a default value of "On".

 

I'd like to create a collection of all of the values that are checked but running into an issue.

 

On my button I have this formula:

rob26r_0-1604328411791.png

 

The formula works when all or none of the vendors are selected. 

 

However, when I change the toggle button on vendor 100 to "Off" my collection is not right - no items show up, see below.  I'm of course expecting to see vendor 200 & 300.

 

rob26r_1-1604328544232.png

 

I can't figure out why this is occurring?  What am I doing wrong?  Thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi@rob26r,

Based on the issue that you mentioned, do you want to collect and remove the corresponding item once the Toggle value changes?

Could you please share a bit more about the scenario?

I agree with @rsaikrishna, the key is to the OnCheck and OnUncheck property of the Toggle. The formula you provided will always collect all the items within the Gallery.

I have a test on my side, please check the following workaround.

My data source is a collection named 'Table1' as below:

 

Collect(Table1,{Vendor:100},{Vendor:200},{Vendor:300})

 

I set the Text property of the Label within the Gallery as below:

 

ThisItem.Vendor

 

Set the OnCheck property of the Toggle as below:

 

Collect(VendorCollect,ThisItem)

 

Set the OnUncheck property of the Toggle as below:

 

Remove(VendorCollect,ThisItem)

 

Set the Items property of the DataTable as below:

 

VendorCollect

 

 

110302GIF.gif

Hope it could help.

Best Regards,

Qi

 

Best Regards,
Qi

View solution in original post

2 REPLIES 2
rsaikrishna
Super User
Super User

@rob26r 

 

Alternate solution:

 

The toggle control has OnCheck , OnUnCheck properties.

 

OnCheck - Collect the vendor number into the collection.

OnUncheck - RemoveIf the vendor number exists in the collection.

 

While the user performing the toggle ON/OFF, the collection will be filled in. So, you can directly use the collection.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

 

v-qiaqi-msft
Community Support
Community Support

Hi@rob26r,

Based on the issue that you mentioned, do you want to collect and remove the corresponding item once the Toggle value changes?

Could you please share a bit more about the scenario?

I agree with @rsaikrishna, the key is to the OnCheck and OnUncheck property of the Toggle. The formula you provided will always collect all the items within the Gallery.

I have a test on my side, please check the following workaround.

My data source is a collection named 'Table1' as below:

 

Collect(Table1,{Vendor:100},{Vendor:200},{Vendor:300})

 

I set the Text property of the Label within the Gallery as below:

 

ThisItem.Vendor

 

Set the OnCheck property of the Toggle as below:

 

Collect(VendorCollect,ThisItem)

 

Set the OnUncheck property of the Toggle as below:

 

Remove(VendorCollect,ThisItem)

 

Set the Items property of the DataTable as below:

 

VendorCollect

 

 

110302GIF.gif

Hope it could help.

Best Regards,

Qi

 

Best Regards,
Qi

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

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.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,115)