cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KPOak-MDIT
Level: Powered On

Collecting the results of a filter

Good evening PowerUser Community ,

 

Is it possible to build a collection on the results of a filter?  I have been trying to do this for a localized training room reservation app that does not rely on centrally managed resource calendars.

 

Specifically, I have a sharepoint list with reservable timeslots by Date, and Room name, where the dates are saved as a text string (i.e. '1/1/2019' not m/m/yyyy) in a column titled "Title". This was done to avoid issues I was encountering with the dates being timestamped when brought into the powerapp, which messed up the room sorting pretty badly.

 

The intent was for an end user to select a date from a date picker, use a hidden text input to convert the date into a text string, then build a collection of available Rooms with a matching date in the Title columnto poulate a data table with the list of resources available on the date selected.

 

The issue is with the formula on the button that populates the table: ClearCollect(availInfo, Filter('Room Schedule',Title=TextInput1.Text))  Where the collection availInfo is the tabgle created from the results of filtering the 'Room Schedule' shartepoint list by the 'Title' field.

 

The formula passes muster in the formula bar, but doesn't collect anything.  What am I missing with this?

 

Any and all guidance is much appreciated by this PowerApps noob.

 

4 REPLIES 4
AndySid
Level 8

Re: Collecting the results of a filter

Hi, 

So if you look under View, collections your collection named availInfo is there, but empty?

 

To replicate in my environment I placed and button with

ClearCollect(availInfo, Filter('appContracts',ContractNo = TextInput1.Text)) Worked fine!

Make TextInput1 visible to confirm a value has been populated?

jag75
Level: Powered On

Re: Collecting the results of a filter

To build on this reply, here's some of my techniques when manipulating collections...

 

Create a couple temporary labels, assign then the values of the variables or collection you're working with. You can see what's going on, behind the scenes. Once you have the logic working, delete these labels. 

 

Add a label, and make the value CountRows(col_MyCollection.AllRows) . This will give you a count of items in the actual collection.

 

For the extreme, create a new screen, and fill with labels that hold ALL your variables and collections. If you ever want to know the value of a collection/variable you can just jump to that screen and see it all. 

Community Support Team
Community Support Team

Re: Collecting the results of a filter

Hi @KPOak-MDIT,

Could you please share a bit more about your scenario?

Do you mean that the availInfo collection is empty within your app?

Further, could you please share a bit more about the data structure of your 'Room Schedule' SP list?

I have made a test on my side, and don't have the issue that you mentioned. The screenshot as below:

The data structure of my SP list as below:3.JPGApp's configuration as below:4.JPG

 

5.JPG

Set the Text property of the Label control (Label1) to following:

 

Text(DatePicker1.SelectedDate)

 

Set the OnSelect property of the "Collect" button to following:

ClearCollect(RecordsCollection, Filter('20190123_case2', Title = Label1.Text))

The RecordsCollection populated well as below:6.JPG

Please check if the Text string format the TextInput1.Text formula returned is the same as that Title column returned.

In addition, I think it is not necessary to add a Hidden text to store the converted Text string value. On your side, please consider take a try with the following formula (set OnSelect property of the Button to following):

ClearCollect(availInfo, Filter('Room Schedule',Title = Text(DatePicker1.SelectedDate)))  

then you could go to File -> Collections tab to see if your availInfo Collection has been populated well.

 

In addition, you could also consider take a try to add a Data Table control within your app, then set the Items property to following:

availInfo

then enable/select proper fields within the Data table, you would see your availInfo collection within the Data table.

 

Best regards,

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
KPOak-MDIT
Level: Powered On

Re: Collecting the results of a filter

Thank you all for the replies - they were helpful in clarifying what the issue wasn't - namely with the expression. My data source is 7K+ records long.  When I used truncated data source as a test (1.5K records) the collection worked as intended. 

 

And v-xida - thank you for the 'TEXT' tip - definitely more elegant that my original solution!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 107 members 4,804 guests
Please welcome our newest community members: