Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

Filter onSelect

Hi I am trying to filter data of My SharePoint List by clicking on the button.


SharePoint List Name: Group Project Tasks

Fields : Person Field named Assigned To


On the screen I set up a button which should filter and show Items in the list where curent User is assigned.


This is what I wrote onSelect for my button:

Filter('Group Project Tasks',Assigned_x0020_to.DisplayName=User().FullName)


Unfortunatelly nothing happens on the screen onSelect.

Power Apps
Power Apps

The Filter function will not change the data source you pass in its first argument; instead, it will return a new collection, based on that data source, filtered by the condition you specify.


What you need to do is to use the filter expression in the Items property of the control (a gallery, I assume) that displays the tasks. If you always want the list to be filtered by the current user, you can use this expression in the Items property:

Filter('Group Project Tasks', Assigned_x0020_to.DisplayName = User().FirstName)

Alternatively, if you want a button to toggle between all items and your items, you can use a context variable and change its value in the button's OnSelect handler:

Button1.OnSelect: UpdateContext({ myTasksOnly: !myTasksOnly })
Gallery1.Items: If(myTasksOnly, Filter('Group Project Tasks', Assigned_x0020_to.DisplayName = User().FirstName), 'Group Project Tasks')

It works as expected but it looks like same button does both operations show all and showMy in different clicks

I would like to have two seperate buttons:

Button 1.Onselect to show All Items and Button2.Onselect to show My only.


Please explain how can I achive this.


In this case you can set the value of the variable to true or false in each of the buttons:

Button1.Text: "Show All Items"
Button1.OnSelect: UpdateContext({ myTasksOnly: false })

Button2.Text: "Show My Items Only"
Button2.OnSelect: UpdateContext({ myTasksOnly: true })

Is there any changes in the Gallery1.Item ?


Currently I have this :

Search(Filter('Group Project Tasks', (ParentID=BrowseGallery1.Selected.ID)) , ActionSearch.Text, "Title")


Which allows me to search also.


Please let me know.


Sorry if I am asking dummy questions, I am just new at iy

You could use the If function to have a conditional expression in the Gallery1.Items property:

    Search(Filter('Group Project Tasks', ParentID = BrowseGallery1.Selected.ID, Assigned_x0020_to.DisplayName = User().FirstName), ActionSearch.Text, "Title"))
    Search(Filter('Group Project Tasks', ParentID = BrowseGallery1.Selected.ID), ActionSearch.Text, "Title"))

If the variable is set to true, then you'd add another parameter to the Filter function; otherwise you can use the expression that you currently have.


You can also rewrite the expression above as shown below if you don't want to repeat yourself. Basically this is moving the 'if condition' to inside the search:

        'Group Project Tasks',
        ParentID = BrowseGallery1.Selected.ID,
        If(myTasksOnly, Assigned_x0020_to.DisplayName = User().FirstName, true)),

I used second version and for some reason I am not getting any results back just blank screen. Any ideas why? I checked the spelling, everything looks ok.

Please let me know if you have an idea why I am not getting result?


Thank you

Not really (will try a few other options here); if you use the first option, does it work?

Helper II
Helper II

Please let me know if you have any results of tests


Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,226)