I have a Gallery called BikeListGallery. It's data source is an entity in the CDS called Bikes. There is a field in said table called BikeCategory which is a lookup. The Bike categories are stored in another entity called BikeCategory.
I have a page in my PowerApp with a gallery for the bikes. The page also has a filter called BikeCategoryFilter for the Bike Category. The items property for the BikeCategoryFilter is the BikeCategory entity. (I have also tried using a collection for the items data source but get similar errors).
I have set the Items property on the BikeListGallery to Filter(Bikes,cr53c_BikeCategory in BikeCategoryFilter.SelectedItems.Name).
I get a delegation warning and no results show in the gallery. The Bike entity has 20-40 records and the bike category has 5 values.
I have tried various varieties of this formula using a collection, using a variable, and I always get invalid argument type errors. I had to use the CDS name of the field to get the invalid argument error to go away instead of the "BikeCategory" which is the name of the field in the CDS. When it was like this it was a "table" type and it would not let me compare to another table type or to another string value.
What am I doing wrong? Ideally I want the drop down to support multi-select (which is currently disabled) but I can't get it to work with a single value let alone multiple.
Hi @Mrsprofitt77 ,
Do you want to filter a gallery based on a selection of lookup field?
I've made a similar test for your reference:
1)set the combo box's Items:
2)set the gallery's Items:
Filter(Bikes,cr53c_BikeCategory.Name in BikeCategoryFilter.SelectedItems.Name).
Then the gallery will only display the items that lookup field value is in the combo box selected values.
Please note that lookup field is a complex data type. One value of lookup field represents one record of the related entity.
The version that you have does work; however, when I add an IF check on this to check for the category being blank, then it stops working. If there is not category selected, I need it to show all the records. Here is the updated version of the formula that I tried to do this, but I get no records when I select a category.
Filter(Bikes,If(IsBlank(gloSelectedCategory), true, cr53c_BikeCategory.Name in BikeCategoryFilter.SelectedItems.Name))
The weird thing is that I was able to work around this whole thing by changing it to a search function instead of a filter function. The search I have does not work with a multi-select, so I disabled that, which is "ok" but not what I really wanted. This is my full working version. Maybe there is a better way to write this, but the only way I could seem to get it to work with the four filters I have was to do nested searches. I also have two filters on it for a Price and an Active field on my entity. The Active field was also weird. I could not figure out how to refer to the native State code field that comes on the CDS table. So I added my own Bike status field. I am guessing that you can't refer to the State code field because it is a local option set? I also tried to just use the built in view on the CDS to select the "Active" records, but the View field was disabled. Maybe that is because I have all this custom code on the items property? Here is the working code sample that I have on the items property of my gallery right now.
Sort( Filter( Filter( Search( Search( Search( Bikes, If( IsBlank(gloSelectedCategory), "", gloSelectedCategory ), "cr746_search" ), If( IsBlank(gloSelectedColor), "", gloSelectedColor ), "cr746_search" ), If( IsBlank(gloSelectedStyle), "", gloSelectedStyle ), "cr746_search" ), 'Bike price' <= PriceRangeFilter.Value ), BikeStatus <> BikeStatusList.Inactive ), 'Bike position' )
Read the announcement for more information!
Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.
Features releasing from October 2019 through March 2020
Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications