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 / Combo Box SearchField ...
Power Apps
Answered

Combo Box SearchField If Statement Not Working?

(0) ShareShare
ReportReport
Posted on by 58

Can you use an If Statement in the SearchField of a Combo Box?  I have a toggle and I would like the search field to be based of a field determined from the toggle. 

 

bcampbell13_0-1612293576455.png

 

For Context, our projects have both a real Name and a CodeName, I want a user to be able to choose which field it will search to find the project they want.  The data source is SQL, both the fields are text fields and we have a lot of rows in the list so the search must be delegated to the server.

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Combobox allows multiple search. If this will not disturb your objective, I suggest you remove the if function and go with;

    ["Column1","Column2"]

    With this both columns could be searched

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

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • bcampbell13 Profile Picture
    58 on at

    I can't use ["Column1","Column2"], because I'd like it to search one or the other. 

     

    The If statement does not seem to work, it will only ever search one of those fields.

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @bcampbell13 :

    I did a test, the function you mentioned really can not be achieved.I suggest you use a combination of controls to accomplish similar functions.For example:

    1\My data source:

    ClearCollect(
     TestCollection,
     {CodeNameClientName:"A",MatterClientName:"X"},
     {CodeNameClientName:"B",MatterClientName:"Y"},
     {CodeNameClientName:"C",MatterClientName:"Z"}
    )

    2\Add a toggle control(SetMatter_SelevtBy_Toggle)

    3\Add a text input control(TextInput1)

    OnSelect

    Set(visible,true) /*visible is my custom variable*/

    4\Add an arrow icon

    OnSelect

    Set(visible,!visible)

     5\Add a list box(ListBox1)

    Items

    Filter(
     TestCollection,
     If(
     SetMatter_SelevtBy_Toggle.Value,
     StartsWith(
     CodeNameClientName,
     TextInput1.Text
     ),
     StartsWith(
     MatterClientName,
     TextInput1.Text
     )
     )
    )

    OnSelect

    Collect(TheResult,ListBox1.SelectedItems) /*TheResult is my custom collection*/

    6\Add a gallery(Gallery3)

    Items

    TheResult

    7\Add a label control into this gallery

    Text

    ThisItem.CodeNameClientName

    8\Add a "X" icon into this gallery

    OnSelect

    Remove(TheResult,ThisItem)

     65.gif

    Best Regards,

    Bof

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,045

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 592

Last 30 days Overall leaderboard