I encountered a challenge when following the guidelines of this article.
In the Step: Writing the related schools into a collection
Faculty Field -> OnChange:
ClearCollect( collSchools, { Schools: Filter( Schools, Faculty.Value = DataCardValue2.Selected.Value ) } )
Property Explanation
collSchools | This is our collection where all related schools for the selected faculty are written in to |
Schools | This is the name of the column where the data is written in to |
Filter | This is the function that filters values from a data set. The format of this function is as follows: Filter(source,logical_test) |
Schools | This is the data set that we use in our filter. In this case, it is the Schools list we added as data source |
Faculty.Value | This is the value we are looking for in our data set. In this case, it is the Faculty lookup field in our Schools list |
DataCardValue2.Selected.Value | This is the selected faculty from our PowerApp |
I follow this fomulas but the result is an empty collSchools Collection.
Here is my Form Setting
And the OnChange of Faculty Dropdown:
And the collSchools Collection: Empty School Column
Can anyone help me resolve this problem?
DataCardValue2 is an arbitrary name provided by the system when you added the data card to the screen. But in your image it shows you've renamed it to drpd_Faculty. So the formula should read.
ClearCollect( collSchools, { Schools: Filter( Schools, Faculty.Value = drpd_faculty.Selected.Value ) } )
@Thanks for the quick answer, @Pstork1.
But my setting is correct as you. You can see the picture I setting.
Are you sure that fields in the Schools list match (including case sensitivity) the entries in the Faculty dropdown list? The collection is being created it just has no data in it. So I suspect your filter statement is returning an empty record set.
Here is my Schools List. And I see everything match the setting in PowerApps (including case sensitivity)
Try this for a quick test. Replace the current statement with the following:
ClearCollect( collSchools, { Schools: Filter( Schools, Faculty.Value = "Faculty of Health" ) } )
See if that provides a collection. YOu could also temporarily add a gallery to your form and set the Items collection to the following to make sure that you are getting a set of records back.
Filter( Schools, Faculty.Value = "Faculty of Health" )
I still think something has to be off in your Filter statement.
I follow your instruction and have the result:
1/ Can't create a collection
2/ Can create a Gallery with
Filter( Schools, Faculty.Value = "Faculty of Health" )
But it default display the Created By Column and ignore the Faculty Column.
What can I do next?
Hi @carem
Create a label for test purpose
Set text property of label to
CountRows(Filter( Schools, Faculty.Value = DataCardValue2.Selected.Value ))
If count is 0, then your query is not correct
also try with
CountRows(Filter( Schools, Faculty.Value = "hardcode a value here and check" ))
--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
It doesn't matter what shows in the Gallery. The whole point was to make sure the filter works to return records.
If you take the other formula and put it in the OnSelect for a button then run the app and press the button do you get a collection?
I set 2 text labels to test your expression.
And both of them return 0.
The warning:
That means my query was wrong. But I couldn't detect any points.
I try the example of Microsoft:
ClearCollect( IceCream, { Flavor: "Strawberry", Quantity: 300 } )
and success.
And I have discovered a serious problem with Preview Mode. I think it is the cause of this problem.
My Preview Function is not working. It's mean when I press F5 you can see my form like this:
Edit Mode
Preview Mode
It may be that it cannot recognize the value of drpd_Faculty.Selected.Value. And return an empty Collection.
Follow Pstork1's advice, I create a button with OnSelect Property:
ClearCollect( collSchools, { Schools: Filter( Schools, Faculty.Value = "Faculty of Health" ) } )
And it's work.
But when I go back for
ClearCollect( collSchools, { Schools: Filter( Schools, Faculty.Value = drpd_Faculty.Selected.Value ) } )
It does not work anymore.
Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.
Did you miss the call?? Check out the Power Apps Community Call here!
User | Count |
---|---|
265 | |
208 | |
76 | |
42 | |
33 |
User | Count |
---|---|
348 | |
223 | |
117 | |
72 | |
54 |