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 / Gallery tied to a sear...
Power Apps
Answered

Gallery tied to a search box gets all items initially

(0) ShareShare
ReportReport
Posted on by 260

Hello

 

I have gallery which has the following in Items

 

Search('My Sharepoint list', SearchBox.Text, "Address")

 

When enter text in the box it correctly filters

 

However, when there is nothing in the search box I dont want it to bring back all of the data

 

I actually want the gallery to be empty

 

Is this possible to do?

 

Paul

Categories:
  • WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at

    Hi @paulinuk ,

    Try this

    Filter(
     'My Sharepoint list', 
     Len(SearchBox.Text) = 0 || SearchBox.Text in Address
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • paulinuk Profile Picture
    260 on at

    Hi 

     

    This has the same issue if the user hasnt entered anything in the search box I dont want to see anything in the gallery control, i.e. I dont want to search/filter if no value has been entered, so the behavior needs to be as if the user entered something that cannot be found

     

    Paul

  • WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at

    @paulinuk ,

    Strangely users generally want it the other way around - use this

    Filter(
     'My Sharepoint list', 
     SearchBox.Text in Address
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • paulinuk Profile Picture
    260 on at

    Thanks I will try this, the problem I have is that I am storing data offline on the device for a diary that contains 1 object per day, without this behavour it would load all the days ever recorded which I am worried would be too much data to store.

     

    I think this is the best approach in this situation?

  • iDLIR Profile Picture
    50 on at

    Try this:
    OnChange property of the SearchBox set a variable (ex.  Updatecontext({varLength: Len(SearchBox.Text)}))
    Then on the visibility of the Gallery put this:
    if(varLength<>0,true,false)

    This way, if you remove all the characters from the searchbox it should make the gallery not visible.

    Give it a try 🙂 

  • paulinuk Profile Picture
    260 on at

    Ok thanks I will try this. I’m assuming that it won’t still call the filter method behind the scenes?

  • paulinuk Profile Picture
    260 on at

    Hello

     

    This doesnt work, even when I resolve the syntax issues

     

    I have tried

     

    Method 1

     

    OnChange of SearchBox: UpdateContext({varLength: Len(SearchBox.Text)})

     

    There is no OnVisible of the gallery control so in the Visible box I put varLength <> 0

     

    I couldnt put if(varLength<>0, true,false) said unknown function/invalid characters

     

    Method 2

    OnChange of SearchBox: UpdateContext({varLength: Len(SearchBox.Text) <> 0})

     

    Visible of Gallery Control: varLength - which should be false when the box is empty

     

    The gallery stays visible when there is no text in the search box?

     

  • Verified answer
    iDLIR Profile Picture
    50 on at

    Hi again,

     

    Please kindly check again. i just tested it and it works.

    Please follow the screenshots below to better understand what i mean 🙂

    OnChange property on the InputBox set it as in the picture

    iDLIR_1-1641996133745.png

     

    Gallery Visible property set it as shown below

    iDLIR_2-1641996189692.png

     

    Let me know if that helps.

    Thanks,

    iDLIR

     

  • paulinuk Profile Picture
    260 on at

    ok thanks this is closer now

     

    But why does OnChange only fire when the user presses enter?

     

    I would expect it to fire as soon as the text is changed?

     

    How can I fix that?

     

    When the screen is loaded the box wont have anything in it so I need the gallery to be invisible

     

    If I use backspace to clear the box the gallery shows until I press enter which is  a bad user experience

     

    Cheers

     

    Paul

  • WarrenBelz Profile Picture
    156,921 Most Valuable Professional on at

    @paulinuk ,

    The OnChange event only initiates when the user changes the value.

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 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
timl Profile Picture

timl 122 Super User 2026 Season 2

Last 30 days Overall leaderboard