web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter gallery by clic...
Power Apps
Answered

Filter gallery by click on a button

(0) ShareShare
ReportReport
Posted on by 82

Dear experts,

I am building an application linked with a SharePoint list I am filtering the gallery with dropdown and search string.

 

My question is I want to filter the gallery  by clicking on a button, so when I click the button i get all the data related to "Finance Team". note that the coulmn is a single line of text.

 

is there a way to do so without a delegation problem, I found a way to do so but if the column was a choices column but the column is a single line of text

 

Thanks in advance

 

Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.
Categories:
  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    Hi @mohamednasr ,

     

    The simplest option is to disregard the buttons and replace them with checkboxes (which you can format like a button).

     

    Then apply the below to the Items property of your Gallery, making explicit reference to each of the Checkbox names:

     

    Filter
    (
     'Your Data',
    
     (!Checkbox_Finance.Value || Team.Value = "Finance Team") 
    
     && (!Checkbox_Legal.Value || Team.Value = "Legal Team") 
    
     && (!Checkbox_HR.Value || Team.Value = "HR Team")
    
    )

     

    If you must really use buttons, then you could apply your Filter parameters (the Filter function in SharePoint is delegable) directly into a local context variable.

     

    On your “Finance Team” button for example, enter the following onto the OnSelect property:

     

    UpdateContext(
     {
     varData: Filter(
     'Your Data',
     Team.Value = "Finance Team"
     )
     }
    )

     

    For another team, use the same principle for a different button:

     

    UpdateContext(
     {
     varData: Filter(
     'Your Data Data',
     Team.Value = "Legal"
     )
     }
    )

     

    Create an optional Reset button and add the following onto the OnSelect property:

     

    UpdateContext(
     {
     varData: 'Your Data'
     
     }
    )

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.
  • mohamednasr Profile Picture
    82 on at

    @Amik 

    Thanks a lot, please if I used the second option  for “Finance Team” button OnSelect property:

    UpdateContext(
     {
     varData: Filter(
     'Your Data',
     Team.Value = "Finance Team"
     )
     }
    )

     

    What should be the formula like on the gallery item then?

     

    Knowing below is the current formula I have for the gallery items: 

     

    Switch(
    varSortColumn,
    "ID",
    SortByColumns(
    Filter(
    'Vendor Invoicing',
    StartsWith(
    EInvoice,
    txtSearch.Text
    )||StartsWith(
    Amount,
    txtSearch.Text)
    ||StartsWith(Vendor,txtSearch.Text)
    ),



    "ID",
    If(
    varSortColumn = SortOrder.Ascending,
    SortOrder.Ascending,
    SortOrder.Descending
    )
    ))

    Thanks a lot 

     

     

     

    Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    Hi @mohamednasr ,

     

    Same principle applies. The Switch expression you're using is not making sense to me (varSortColumn = SortOrder.Ascending ?? ), but if we exclude that for a moment, you can use:

     

    UpdateContext(
     {
     varData: Filter(
     'Vendor Invoicing',
     StartsWith(
     EInvoice,
     txtSearch.Text
     ) || StartsWith(
     Amount,
     txtSearch.Text
     ) || StartsWith(
     Vendor,
     txtSearch.Text
     )
     )
     }
    )

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.
  • mohamednasr Profile Picture
    82 on at

    @Amik 

    Thanks a lot really appreciate your help

    Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.Liquid error: Exception has been thrown by the target of an invocation.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard