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

Filter dataset based on collection items

I hope this will be simple and something I am just overlooking...I have a gallery with a list of checkbox inputs and yes, can be multiselected.  OnCheck, the ID is stored into a collection.  I have a second gallery that is reference through the IDs that are captured in the collection.  How do I filter this second gallery items from the selected item(s) from the first gallery?  And is there even a need for a collection, or can I just use some ForAll(Gallery1.Selected) statement?

 

Thanks for the information

1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @guyinkalamazoo ,

 

I did a test for you:

1\ This is my list 'LIST114'.

v-xiaochen-msft_0-1619061710927.png

 

2\ Set the OnVisible property of the screen to:

ClearCollect(TestCol,LIST114)

// This step is important. It is not recommended to omit. If you directly operate on the data source may return a null value.

 

3\ Add a gallery control and set its Items property to:

Table({ID:1},{ID:2},{ID:3})

v-xiaochen-msft_2-1619061841560.png

 

4\ Insert a check box control into this gallery and set its Oncheck property to:

Collect(Col,ThisItem.ID)

 

Set the check box control's Onuncheck property to:

Remove(Col,LookUp(Col,Value=ThisItem.ID))

 

5\ Add another gallery control and set its Items property to:

Ungroup(ForAll(Col,Filter(TestCol,NumberColumn=Value)),"Value")

 

6\ The result is as follows:

AAA.gif

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

3 REPLIES 3
v-xiaochen-msft
Community Support
Community Support

Hi @guyinkalamazoo ,

 

I did a test for you:

1\ This is my list 'LIST114'.

v-xiaochen-msft_0-1619061710927.png

 

2\ Set the OnVisible property of the screen to:

ClearCollect(TestCol,LIST114)

// This step is important. It is not recommended to omit. If you directly operate on the data source may return a null value.

 

3\ Add a gallery control and set its Items property to:

Table({ID:1},{ID:2},{ID:3})

v-xiaochen-msft_2-1619061841560.png

 

4\ Insert a check box control into this gallery and set its Oncheck property to:

Collect(Col,ThisItem.ID)

 

Set the check box control's Onuncheck property to:

Remove(Col,LookUp(Col,Value=ThisItem.ID))

 

5\ Add another gallery control and set its Items property to:

Ungroup(ForAll(Col,Filter(TestCol,NumberColumn=Value)),"Value")

 

6\ The result is as follows:

AAA.gif

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

Wearsky,

Thanks for the post.  I have most of it working, except the Ungroup function for the Items in the second gallery.  I have this formula (per your post): Upgroup(ForAll(SelectedBarrier,Filter('Barrier Reason',BarrierID=Value)),"Value").

 

'Barrier Reason' is a relational table that links BarrierID back to the main Barrier Table.  It is a many (reasons) to one (barrier) relationship.  Business rules say that many barriers can be selected.  My goal is to have only the reasons that match the selected barriers to be listed in the Reasons Gallery.  

 

Right now I am able to select the barriers and SelectedBarrier (the collection) is storing the BarrierID with no issue.

 

The checkbox on the reasons form text is set to ThisItem.Title.

 

Thanks for the advice

guyinkalamazoo
Frequent Visitor

Actually Wearsky it now works great!  I had a small syntax error.  Thanks for the information

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (21,264)