web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Search Gallery using t...
Power Apps
Unanswered

Search Gallery using text and number fields

(1) ShareShare
ReportReport
Posted on by
I am trying to set up a gallery search using text fields (Name & Age) and number field (ID which is a system column from a Sharepoint List). Age is a calculated field and has text content like this: "11 yrs 8 mos"
 
I have 2 search boxes, one for text (PTNameSearch) and one for number (PTIDSearch).
 
Here's my search logic: if PTNameSearch box is not blank, then search by Name & Age value else if PTIDSearch box is not blank then search by ID, else return all records.
 
If(!IsBlank(PTNameSearch.Value),
    Search(SortByColumns('EMR PT Demographics',"ID"), PTNameSearch.Value,'Patient Name', Age),
    If(!IsBlank(PTIDSearch.Value),
       Filter(SortByColumns('EMR PT Demographics',"ID"),Value(PTIDSearch.Value),ID),
    SortByColumns('EMR PT Demographics',"ID")))
 
The text search works fine, but the number search does not return a result.
 
What is wrong with my number search?
 
Thank you.
Categories:
I have the same question (0)
  • Suggested answer
    MichaelFP Profile Picture
    1,847 Super User 2025 Season 2 on at
    The Search() is to find a string, that could be in any place of columns of type text. For numbers will not work. you need for that case to use Filter() to apply by Age.
     
  • CU24081716-3 Profile Picture
    on at
    Thank you, Michael, for jumping in. The Age field here is Text. It is a calculated field from DOB field. Its content has this format "11 yrs 8 mos".
     
    As shown below, searching by Age works just fine:
     
     
    The problem I'm experiencing is the filter by ID: Filter(SortByColumns('EMR PT Demographics',"ID"),Value(PTIDSearch.Value),ID)
     
    This Filter() statement isn't returning anything.
     
     
  • CU24081716-3 Profile Picture
    on at
    I also removed the name search and use just the filter:
     
    If(!IsBlank(PTIDSearch.Value),
           Filter(SortByColumns('EMR PT Demographics',"ID"),Value(PTIDSearch.Value),ID),
        SortByColumns('EMR PT Demographics',"ID"))
     
    Still does not work! :-(
  • WarrenBelz Profile Picture
    153,032 Most Valuable Professional on at
    I thought  I would throw in this idea
    Search(
       SortByColumns(
          Filter(
             AddColumns(
                'EMR PT Demographics',
                IDTxt,
                Text(ID)
             ),
             Len(PTIDSearch.Value) = 0 ||
             PTIDSearch.Value in IDTxt
          ),
          "ID"
       ),
       PTNameSearch.Value,
       'Patient Name', 
       Age
    )
     
  • CU24081716-3 Profile Picture
    on at
    Brilliant to use AddColumns, Warren! Your solution works! The only change I made is to replace the operator "in" in the Filter with "=". With the "in" operator, if I search for ID of 8, I would get records for ID = 8, 18, 28, etc. But with the "=" operator, the search is exact.
     
    Thank you so much!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard