cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Filter gallery for blank items in combo box

Hi all,

 

I've had a look around online and in the forum and not found quite what I was looking for.

I'm using a SharePoint list as my data source to populate a gallery. I've created a collection to populate a dropdown box like this:

 

 

 

ClearCollect(fruitList,"<Unassigned>");
Collect(fruitList,RenameColumns(ShowColumns(Fruit,"fruitType"),"fruitType","Value"))

 

 

 

 So far so good. I have a collection with the first item being "<Unassigned>" and the rest of the fruit below that.

 

What I'd like to do is be able to filter my gallery specifically on "<Unassigned>", and to return only those records where the fruit type is blank.

I've tried my code like this:

 

 

 

Filter(Sales,
  Or(
    IsBlank(ComboBoxFruit.SelectedItems),
    IsEmpty(ComboBoxFruit.SelectedItems),
    fruitType = Substitute(Last(FirstN(ComboBoxFruit.SelectedItems,1)).Value,"Unassigned>",Blank()
  )
)

 

 

 

I was hoping PowerApps could do the simple substitute for a Blank() result and compare that against the SP list but no luck.

When I test like this:

 

 

 

Filter(Sales,fruitType = Blank())

 

 

 

... it works just fine.

 

Thank you in advance,

Attila

3 REPLIES 3
v-xiaochen-msft
Community Support
Community Support

Hi @Attila_the_Hun ,

 

Please try this:

If(ComboBoxFruit.Selected,Value="<Unassigned>",Filter(Sales,fruitType = Blank()))

 

Best Regards,

Wearsky

Thanks for the suggestion, but my items property on the gallery is already very complex based on several if conditions. This has arisen from the simple fact I can't use a variable from within the app in my SortByColumns function without hitting delegation.

 

If I were to use your solution I'd have to create a whole new set of If conditions to sort my data.

v-xiaochen-msft
Community Support
Community Support

Hi @Attila_the_Hun ,

 

The formula you provided is inconsistent with your needs so I can't modify your formula.

 

Best Regards,

Wearsky

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,203)