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 / Not able to search bas...
Power Apps
Answered

Not able to search based on a dropdown value.

(0) ShareShare
ReportReport
Posted on by 826 Moderator

 

The dropdown contains all the column headers of my DataSource. I was able to display them all by creating a sharepoint list and manually adding the column headers there. 

My goal: is to be able to search by typing in the search box and then choose from the dropdown. I set a variable on the search button OnSelect property Set(varSource,true) so that I can give an If statement to my gallery items



My current gallery items formula that is working(hard coded for testing): 

If ( varSearch, Search(DataSource,txtSearch.Text, "Category"), DataSource) -> this formula currently works and able to search for "Category" column, knowing that this works probably I might have something wrong with my formula that is referencing the text value of the dropdown.

however when I change the gallery items formula to 

if (varSearch, Search(DataSource, txtSearch.Text, dropdown.SelectedText.Value),DataSource)

it gets a formula error.

 

Questions:

1)How can I search based on a dropdown value? 

2)Where should I change the value of varSearch to false, so that whenever I want to search for another I have to click the search button. Ive tried this formula in my gallery items properties
if (varSearch, Search(DataSource, txtSearch.Text, dropdown.SelectedText.Value),DataSource); Set(varSource,false) but I also get an error

powerappsquestion.png

Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @kej ,

     

    PowerApps is static so you cannot use the value of dropdown to refer to the column name.

    Please try this

    If ( varSearch && dropdown.Selected.Value="value1", 
    Search(DataSource,txtSearch.Text, "Column1"), 
    varSearch && dropdown.Selected.Value="value2", 
    Search(DataSource,txtSearch.Text, "Column2"), 
    ...,
    DataSource) 

     

    Best Regards,

    Wearsky

  • Verified answer
    turnerj3 Profile Picture
    2,039 on at

    Unfortunately, powerapps won't let you call a column without hardcoding by text.

    You could set up a multiple If statement for each dropdown value like:

    If(dropdown.SelectedText.Value="Category", Search(DataSource, txtSearch.Text, "Category"),dropdown.SelectedText.Value="Column2", Search(DataSource, txtSearch.Text, "Column2"))

  • KevinGador Profile Picture
    826 Moderator on at

    would have selected this answer but when I tried, dropdown no longer accepts .Selected.Value, now its SelectedText.Value

  • KevinGador Profile Picture
    826 Moderator on at

    thank you! do you have any clue on my question number 2?

  • turnerj3 Profile Picture
    2,039 on at

    No problem, what is your gallery items code now?

  • KevinGador Profile Picture
    826 Moderator on at

    its like what you Stated,

    If( varSearch && drpColumnHeaders.SelectedText.Value = "Category",
       Search(DataSource, txtSearch.Text, "Category"),
       .....
       DataSource)

    One more problem that I encountered is I am having a formula error with one of my column type which is a choice. It says wrong column type. Expects text type, however all this formulas are identical only with this column did not work.

  • turnerj3 Profile Picture
    2,039 on at

    Try setting varSearch false immediately after setting it true and see if the search completes. 
    For the choice column try using “column”.value

  • KevinGador Profile Picture
    826 Moderator on at

    "ColumnName".value did not work. I deleted it first in my gallery items to check the varSearch. Setting it to false immediately after did not work too. But the gallery items are working I just had to remove my choice column at the moment. 

    And delagation warning which I will try to figure out soon too.


  • turnerj3 Profile Picture
    2,039 on at

    I think the problem with varSearch is that anytime you set it false it is going to wipe the gallery because the IF depends on it.

    You could use a button to set it false.

     

    Not real sure about the choice column at the moment.

  • KevinGador Profile Picture
    826 Moderator on at

    I solved my question number two, by putting the Set(varSearch,false) into my txtSearch onchange property.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard