Showing results for 
Search instead for 
Did you mean: 

Collection not filtering

I have a custom form that grabs records from a second list.   When the powerapp starts, I grab all of the records from this list, and put it in a collection (col_AllItems).  When a user clicks on an item in the primary list, I try to filter the col_AllItems collection by the ID of the selected item and put the results in a new collection (col_ItemView).  This was working fine until yesterday when I was troubleshooting a different issue with the form.  Below is the code, let me know if I inadvertently screwed something up.  I can't see that I did.  I need a different set of eyes on this, any help is appreciated.



ClearCollect(col_AllItems, SortByColumns('Sales Item List', "ID",Descending))


SharePointIntegrations -> OnView

Set(var_selectedRecord, SharePointIntegration.Selected);

ClearCollect(col_ItemView, ShowColumns(Filter(col_AllItems, var_selectedRecord.ID in 'Request ID'), "ItemName", "ItemDescription", "ItemQuantity"))

Community Support Team
Community Support Team

Re: Collection not filtering

Hi @lumberjacklurch ,

Actually, I couldn't find any error in your formulas.

Could you tell me what did you do when you troubleshooted a different issue with the form?

I'm not sure whether the operation effects the collection.

Is ID and  'Request ID' the same data type?

Is 'Sales Item List' and this list not too large?

Please notice that since you set this formula in OnView, the collection will only be created when you view the custom form, not edit or add.



Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Re: Collection not filtering


Let me preface this reply with a description of an additional issue with this form.  Each item/request in the primary list has cooresponding item records in the secondary list.  When you view a request, the cooresponding item records should display in a gallery at the bottom of the customized form.  However, what's been happening when you click on a request is,  the form displays, but the gallery does not:




I tried using a label, set it's Visible property to check if the variable wasn't empty.  It was fine.  I then set the Visible to check if the collection (col_ItemView) wasn't empty.  The label was visible, implying it wasn't empty, yet it doesn't show when you initially click on a request.  Now, if you click away/cancel the viewing of the form and click on the request again, it shows all of the items from the item list, not just the ones for the request you selected.



This is what was originally happening when I opened this discussion yesterday.


After reading your reply, I checked, and the ID and 'Request ID' were not the same type.  'Request ID' was Single line of text.  I  changed it to Number.  After I refreshed, clicked on a request, the item list/gallery didn't show at all.  I changed it back.


The 'Sales Item List' is not large at all, it only has 4 records.


The only troubleshooting/code changes that I made was to break out the selected ID.  So instead of using var_selectedRecord.ID, I made a new variable called var_selectedRecordID and set it to SharePointIntegration.Selected.ID and put that in the ClearCollect line.  When that proved unhelpful, I changed it back, and here we are.

Helpful resources


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,117)