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.
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?
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.
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:App's configuration as below:
Set the Text property of the Label control (Label1) to following:
Set the OnSelect property of the "Collect" button to following:
ClearCollect(RecordsCollection, Filter('20190123_case2', Title = Label1.Text))
The RecordsCollection populated well as below:
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:
then enable/select proper fields within the Data table, you would see your availInfo collection within the Data table.
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!