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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,332)