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 / Search Gallery using t...
Power Apps
Suggested Answer

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,999 Moderator 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
    155,350 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

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 875

#2
Valantis Profile Picture

Valantis 530

#3
11manish Profile Picture

11manish 432

Last 30 days Overall leaderboard