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 / Adding a Second Field ...
Power Apps
Answered

Adding a Second Field to Search

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

My app currently searches the "Title" field but I want it to also search the "ID" field. The function is listed below.

 

SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

How would I modify this to also allow searches for "ID"?

 

 

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous,

    You would add an "Or" condition to the filter.  

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text) || ID=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Drrickryp Thanks for your response.  The ID field is actually "SFDC ID" so I had to amend your code to:

     

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text) || ThisItem.'SFDC ID'=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

    I also tried this but both threw errors.

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text) || 'SFDC ID'=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

     

    Error message
    function code error.PNG

     My app is already searching the 'Title' (Pursuit Name) field and I need to also search 'SFDC ID' (OPX Number).  I just couldn't find anything that would work.  Any recommendations are appreciated.

    function code 3 fields.PNG

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Try it without the Value() function 

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text) || 'SFDC ID'=TextSearchBox1.Text), "Title", If(SortDescending1, Descending, Ascending))
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks.  I tried the new code you recommended and the error is gone but it will not search. When I try a search on SFDC IS, iget nothing, but it still works when I searched by Title. 

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous,

    I tried it on my side and it works perfectly.  I can't see why it doesn't work for you.  Filtered on nameFiltered on name

     

    Filtered on IDFiltered on ID

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Drrickryp I think I'm getting closer to a solution.  As a test, I replaced my original code where it was searching "Title" to searching "SFDC ID".  Notice that to get it wkg, I had to use "SFDC_x0200_ID" which happen to popup as a suggestion while editing code.

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith('SFDC ID', TextSearchBox1.Text)), "SFDC_x0020_ID", If(SortDescending1, Descending, Ascending))


    I thought I could get your code wkg by using "SFDC_x0200_ID" but it isn't wkg.  What are the differences between "SFDC_x0200_ID" and "SFDC ID"? Any recommendations on editing the code? 

  • TimRohr Profile Picture
    669 on at

    I see a "*1" in @Drrickryp's formula in the screenshot. Is this to change text into a number to match the Type for the ID field? I know you were using the Value() function to do the same thing, but you might try that.

     

    And the _x0020_ is just a placeholder for spaces in a name that has to be rendered without spaces. You should be fine using 'SFDC ID' (single quotes), the way you were.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @TimRohr - Thanks for the clarification and suggestions. Regarding my earlier code involving the use of the Value function, I caught a typo for  TextSearchBox1 (see below). After correcting this, replacing Value with .Text*1 still failed to provide a solution and the Value function did not work either. 

     

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', StartsWith(Title, TextSearchBox1.Text) || 'SFDC ID'=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))


    Is combining default sorting band search code a best practice or is it better to separate out the search code and attach to the search text box?  Alternately, do you have any recommendations on how to tweak the existing code? Any info is greatly appreciated.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at
     

    Hi @Anonymous,

    The sort should not have any effect on the filter.  Try separating the filter conditions and try filtering on just the 'SFDC ID' column.  Make sure that 'SFDC ID' is the actual column name.  The types have to match also, text with text and number with value.  Once you get that to work, add the other condition back in. 

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', 'SFDC ID'=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks, @Drrickryp for the reply. When I tried your code, I got the following error: "Incompatible type. We can't evaluate your formula because the values being compared in the formula aren't the same type. The left value is a Text type and the right value is a Number type".

     

    SortByColumns(Filter('New DXC SharePoint Pursuit Site Request Form', 'SFDC ID'=Value(Textsearchbox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

    The error message "The left value is a Text type and the right value is a Number type" is puzzling since both fields from the SP list are single line text fields (i.e., both text data type). Any recommendations are greatly appreciated.

     

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 356

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard