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 / Search and Filter on I...
Power Apps
Answered

Search and Filter on Items

(0) ShareShare
ReportReport
Posted on by 381

Hi. 

I have the following code to search my gallery. The code is on the Items Action of the gallery. 

 

Search(
'DataSourceName)',
SearchBox.Text,
"Name"
)

 

This works fine. 

 

I would like to also include a filter on the items action to say Filter(DataSourceName, Name.Email = User().Email)

 

A) How do i include both the Search and the filter on the same items action. 

I tried the below, but it doesnt like it 

 

Search(
'DataSourceName)',
SearchBox.Text,
"Name"
) & Filter('DataSourceName,'Name'.Email = User().Email))

 

B) Once the filter is applied and step A above is working. 

How can i create a button to say, clear the filter so every item is shown. 

 

Thanks

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Search(Filter(DataSourceName, Name.Email = User().Email),SearchBox.Text,"Name")

     

    Add a button. OnClick of button:

    Set(varFilter,!varFilter);

    Gallery Item code:

    If(varFilter,Search(Filter(DataSourceName, Name.Email = User().Email),SearchBox.Text,"Name"),DataSourceName)

  • Vstar19 Profile Picture
    381 on at

    If(
    varFilter,
    Search(
    Filter(
    Sort(
    'DataSourceName)',
    Name,
    Ascending
    ),
    'Owner'.Email = User().Email
    ),
    SearchBox.Text,
    "Name"
    )
    )

     

    There is no error with the code, but the gallery is not returning anything back?. If i remove the If(
    varFilter, IT Works. 

    But i need the filter and i need the button to clear the filter?

     

    Any ideas?

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Show Your button on Click code

  • Verified answer
    zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    If(varFilter,
    Search(
    Filter(
    Sort(
    DataSourceName
    ,"Name",
    Ascending
    ),
    'Owner'.Email = User().Email
    ),
    SearchBox.Text,
    "Name"
    ),DataSourceName)

     

    Your brackets are all messed up

  • Vstar19 Profile Picture
    381 on at

    Set(varFilter,!varFilter); my onselect button code. 

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Screen OnVisible:

    Set(Set(varFilter,true);

    Button OnClick:

    Set(varFilter,!varFilter);

    Gallery Item:

    If(varFilter,
    Search(
    Filter(
    Sort(
    DataSourceName
    ,"Name",
    Ascending
    ),
    'Owner'.Email = User().Email
    ),
    SearchBox.Text,
    "Name"
    ),DataSourceName)

  • Vstar19 Profile Picture
    381 on at

    Thank you very much. That sorted it. 

     

    One last question, on the button - how can i make the text dynamic. 

    E.g. when i press the button, it filters the gallery - so i would like the button to say View All. 

    Then when View All is shown, i would like the button text to display, View My 

     

    Is that possbile?

  • Verified answer
    zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Text Property of Button:

    If(varFilter,"View My","View All")

  • Vstar19 Profile Picture
    381 on at

    Thank you very much. You have been a great help. 

    These little helpful tips go a long way in helping me (and others) in building robust solutions. 

    You are a credit to the community. 

    Thank you once again. 

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Thank you for the kind words. Glad it worked out for you.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard