cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
joshieboy
Helper V
Helper V

Create dropdown filter in PowerApps

Hi all,

I have an app that I am trying to create a filter for that somehow I can't seem to get right.  The data source is a SharePoint list called 'Initial Incident Notification' and the field I want to filter on is called 'Investigation_Level'.  This is a text field, however it is based on a calculation of other fields so based on other fields being filled out, the Investigation level can either be automatically populated with a 1, 2 or 3.  Some records are also blank until they are updated.  At present this is one of the biggest things I want to achieve.  I want my dropdown to be able to filter by blanks which is important to mgmt to see these records at a glance, all 1,'s 2's or 3's and also be able to reset to show all records in the gallery.  Any guidance on this appreciated.  

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi Joshua

 

Can you try this? I included the Blank as well.

 

Set OnVisible property of the Screen

ClearCollect(
    ColInvestigationLevel,
    {Result: ""},
    {Result: "All"}
);
Collect(
    ColInvestigationLevel,
    Sort(
        Distinct(
            'Initial Incident Notification',
            'Investigation_Level'
        ),
        Result
    )
)

 

Set the Items property of the Dropdown (InvestLevelDropdown) to

ColInvestigationLevel

 

Set the Items property of the Gallery to

With (
    {AllItems: 'Initial Incident Notification'},
    If(
        IsBlank(InvestLevelDropdown.Selected.Result) || Len(InvestLevelDropdown.Selected.Result) = 0,
        Filter(
            AllItems,
            IsBlank('Investigation_Level')
        ),
        Filter(
            AllItems,
            InvestLevelDropdown.Selected.Result = "All" || 'Investigation_Level' = InvestLevelDropdown.Selected.Result
        )
    )
)

Note: I used With to avoid delegation warning. I believe you are aware of PowerApps max limitation in your settings (Max of 2000). You may need to add other filters along with Investigation Level when the record count goes more than 2000.


Thanks, Stalin (Microsoft MVP)
Blog - Learn To Illuminate Blog
YouTube - Learn To Illuminate Videos

 

View solution in original post

6 REPLIES 6
Drrickryp
Super User
Super User

@joshieboy 

It is not clear to me what you are trying to filter.  Typical would be a data table or gallery filtered by a dropdown control. Is this what you want to do?  If so, the screenshot shows a typical way to do this.  Instead of a button, you can use the formula in the top left in the OnVisible property of the screen.  The dropdown uses "mydata" as its Items property.

_3.jpg

joshieboy
Helper V
Helper V

@Drrickryp - it is a gallery I would like to filter.  Thanks.

Vide supra

joshieboy
Helper V
Helper V

Hi @Drrickryp - I'm not sure I follow from your example above.  Is there anyway you can show me how this will work with my fields listed?

Drrickryp
Super User
Super User

@joshieboy 

Assume your dropdown is called Dropdown1,

Items property for dropdown can be simplified to ["ALL","1","2","3"]

Items property for the Gallery:

If(
   Dropdown1.Selected.Value =  "ALL", 'Initial Incident Notification' ,
   Filter(
          'Initial Incident Notification' , 'Investigation_Level' = Dropdown1.Selected.Value
  )
)

StalinPonnusamy
Super User
Super User

Hi Joshua

 

Can you try this? I included the Blank as well.

 

Set OnVisible property of the Screen

ClearCollect(
    ColInvestigationLevel,
    {Result: ""},
    {Result: "All"}
);
Collect(
    ColInvestigationLevel,
    Sort(
        Distinct(
            'Initial Incident Notification',
            'Investigation_Level'
        ),
        Result
    )
)

 

Set the Items property of the Dropdown (InvestLevelDropdown) to

ColInvestigationLevel

 

Set the Items property of the Gallery to

With (
    {AllItems: 'Initial Incident Notification'},
    If(
        IsBlank(InvestLevelDropdown.Selected.Result) || Len(InvestLevelDropdown.Selected.Result) = 0,
        Filter(
            AllItems,
            IsBlank('Investigation_Level')
        ),
        Filter(
            AllItems,
            InvestLevelDropdown.Selected.Result = "All" || 'Investigation_Level' = InvestLevelDropdown.Selected.Result
        )
    )
)

Note: I used With to avoid delegation warning. I believe you are aware of PowerApps max limitation in your settings (Max of 2000). You may need to add other filters along with Investigation Level when the record count goes more than 2000.


Thanks, Stalin (Microsoft MVP)
Blog - Learn To Illuminate Blog
YouTube - Learn To Illuminate Videos

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,695)