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 / Text Input used for a ...
Power Apps
Answered

Text Input used for a search bar, issues with using a variable in the Default property

(0) ShareShare
ReportReport
Posted on by 439

I have a text input called SearchBox_2. The Default property was automatically set to just "" (empty quotes).

 

I've also got a gallery with the Items property set to
Search(ContactsCollection, SearchBox_2.Text, "cr8e0_contact_name")
This has been working exactly as expected. The records in the gallery change based on what's typed into the text input.

 

However, when I try to make the Default of the text input contain a variable (_searchDefault), nothing shows up in the gallery at all until you type something. Even though _searchDefault is initally set to "", just like the Default property of the text input was originally.

 

I want the default to be a variable because then I can automatically change what's in the results/gallery based on a button my users will click, but they can also type in the search bar and change what's there themseleves, before or after whatever buttons they click. I don't want to hardcode the filter; they need the option to change it. Is there no way to do this? I set _searchDefault on visible of the page, and I've tried

 

Set(_searchDefault, "")
Set(_searchDefault, " ")
Set(_searchDefault, Blank())

 

But no matter what I do, the gallery is completely empty until they type something in. Is there no way to accomplish this? Why does "" work when typed directly into the Default of the text input, but the same value in a variable does not?

Categories:
  • Verified answer
    Pstork1 Profile Picture
    69,665 Most Valuable Professional on at

    Go ahead and set the Default for the search text box to the variable.  Then use an IF statement in your Search like this.

    IF(SearchBox_2.Text = _searchDefault,Search(ContactsCollection, _searchDefault, "cr8e0_contact_name"),Search(ContactsCollection, SearchBox_2.Text, "cr8e0_contact_name"))

    That will search against the default value wehnever the search box is equal to the default value. This will avoid the problem of having to actually apply the value to the search box through a carriage return to get the filter to re-evaluate.

  • Verified answer
    RBoneck Profile Picture
    439 on at

    I actually didn't need to do that at all. It turns out, I just had to close and reopen the app for edit again...

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 283

#3
Mohsin Ali Profile Picture

Mohsin Ali 221

Last 30 days Overall leaderboard