cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Dvictor881
Level: Powered On

All values filter - dropdown values

I have a SharePoint list with field "EventType" which contains choices

  

1) Internal

2) External

 

I am creating a dropdown control in powerapps based on SharePoint data source. Dropdown control on the form is only showing two values Internal and External. I am able to filtering based on each one of them but I would like to add "All Events" choice in the drop down which shows all events when users first load the screen. I have added a new choice option in SharePoint field "All Events" but it didn't work as none of the list items are using that choice. I know how to do filtering based on the choice field but I am struggling to show the All values field in the dropdown. Here are my current settings for dropdown field:

 

DropDown control, Items: Distinct(Events, EventType.Value)

(Events: List Name and EventType: field)

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: All values filter - dropdown values

You can use the If function to either have all events (if the choice is "all events"), or filter based on the event type. For example, those would be the properties you'd need to set:

Dropdown1.Items: ["Internal", "External", "All Events"]
Gallery1.Items:
If(
Dropdown1.Selected.Value = "All Events",
Events,
Filter(Events, EventType.Value = Dropdown1.Selected.Value))

That should work for SP lists.

 

Another option is to have the "All Events" have a value that will match any items - for example, using the StartsWith function. In the example below, if the user chooses the "All Events" option in the dropdown, the gallery will have all items whose event type starts with an empty string (and all valid strings start with an empty string), effectively returning all events.

Dropdown1.Items:
    Table(
        {Value:"Internal", ColumnStart: "Internal"},
        {Value:"External", ColumnStart: "External"},
        {Value:"All Events", ColumnStart: ""})

Gallery1.Items:
    Filter(
        Events,
        StartsWith(EventType.Value, Dropdown1.Selected.ColumnStart))

View solution in original post

4 REPLIES 4
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: All values filter - dropdown values

You can use the If function to either have all events (if the choice is "all events"), or filter based on the event type. For example, those would be the properties you'd need to set:

Dropdown1.Items: ["Internal", "External", "All Events"]
Gallery1.Items:
If(
Dropdown1.Selected.Value = "All Events",
Events,
Filter(Events, EventType.Value = Dropdown1.Selected.Value))

That should work for SP lists.

 

Another option is to have the "All Events" have a value that will match any items - for example, using the StartsWith function. In the example below, if the user chooses the "All Events" option in the dropdown, the gallery will have all items whose event type starts with an empty string (and all valid strings start with an empty string), effectively returning all events.

Dropdown1.Items:
    Table(
        {Value:"Internal", ColumnStart: "Internal"},
        {Value:"External", ColumnStart: "External"},
        {Value:"All Events", ColumnStart: ""})

Gallery1.Items:
    Filter(
        Events,
        StartsWith(EventType.Value, Dropdown1.Selected.ColumnStart))

View solution in original post

nickduxfield
Level 8

Re: All values filter - dropdown values

Now thats a good solution

Peren
Level: Powered On

Re: All values filter - dropdown values

I have tried this and when the if satment is true, it dosen return any items on just returning Events..

Super User
Super User

Re: All values filter - dropdown values

Just a bit of extra bells and whistles... I read my data from a supporting table in the database so I need to take a few extra steps:

 

  • First I create the collection with my Select all (Alla leverantörer) item and empty Search value (Sök)
  • After that I collect the data from my table, sorting it in the process
  • Lastly, I use UpdateIf to set the search value with the name for all items that is not the Select all 

It works like a charm, so thanks for the initial suggestions.

 

 

ClearCollect(cLeverantorer; {Namn:"Alla leverantörer"; Sök:""});;Collect(cLeverantorer; Sort('[dbo].[Leverantor]'; Namn).Namn);;UpdateIf(cLeverantorer; Namn <> "Alla leverantörer"; {Sök:Namn})

 

 

I have another app though that needs to do the same things, but with a number, as opposed to a text in the example above. It works for all the individual items, but what should I set the Select all to? If I leave it blank I get only the records that have a null value. I guess I should let the field have a default value of 0, since 0 has no meaning otherwise.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 207 members 5,549 guests
Please welcome our newest community members: