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 by text Field
Power Apps
Answered

Search by text Field

(0) ShareShare
ReportReport
Posted on by 201

I have been following Reza's video Power Apps Tutorial - Responsive Screen with Gallery & Filters - Beginner to Advanced (youtube.com)

 

I'm having trouble with the search by function as my Name Field is a person column in sharepoint. 

 

I added a text field on my sharepoint list and form called Name Text that looks up the Name field and displays it using the below in the value field. (will just make this not visibile on the form, haven't yet)

 

Value

 

ThisItem.'Name'.DisplayName
 
For the search I have a text input box called txtName and the below it the items of my gallery
 
Items
 
Search('NDT Tracker',txtName.Text,NameText)
 
It displays everything without errors but I cannot search. What am I missing?
 
Categories:
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @ScablandsKing - I am not clear on your solution but the answer to the problem is to understand that the Search function only runs on a string, not on a complex data type like a People field.

     

    You can use the Add Columns function create a "virtual" text column which is populated with the DisplayName attribute of your People field. You can then run your Search on that column.

     

    Search(
     AddColumns(
     'NDT Tracker',
     DisplayNameText,
     Name.DisplayName
     ),
     txtName.Text,
     DisplayNameText
    )

     

    Notes:

     

    The above function not going to add that column to your actual data source. This function is scoped to that formula only

     

    Note despite the lack of a warning, the Add Columns function is not delegable.

     

    Note that "shaping" or "transform" functions like AddColumns modify the table schema of your Gallery. If you have an Edit Form control which is bound to a selected item in the Gallery, this will result in an error.

     

    The reason is because the table schema used in the DataSource and the Item property of the Edit Form must be the same. Given we have just modified the table schema in the Gallery, the table is now different to what the Item property of the Edit Form is expecting.

     

    The typical workaround is to use a LookUp function in the Item property of your Edit Form to return the correct record:

     

    LookUp(
     'NDT Tracker',
     ID = Gallery1.Selected.ID

     

    Further reading: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-table-shaping 

  • ScablandsKing Profile Picture
    201 on at

    @Amik thanks as always! I had added my own text column but this is much easier!

  • ScablandsKing Profile Picture
    201 on at

    @Amik can I add two more person columns and make those searchable as well? what would that look like?

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @ScablandsKing - 

     

    Search(
     AddColumns(
     'NDT Tracker',
     DisplayName,
     Name.DisplayName,
     AnotherDisplayName,
     Name2.DisplayName,
     YetAnotherDisplayName,
     Name3.DisplayName
     ),
     txtName.Text,
     DisplayName,
     AnotherDisplayName,
     YetAnotherDisplayName
    )
  • ScablandsKing Profile Picture
    201 on at

    @Amik 

    I have this working 

    Filter(Search(
     AddColumns(
     'NDT Tracker',
     DisplayNameText,
     Name.DisplayName
     ),
     txtName.Text,
     DisplayNameText
    ),
    
     (cbxMethod.Selected.Value = Method.Value || IsBlank(cbxMethod.Selected.Value)),
     (cbxLevel.Selected.Value = Level.Value || IsBlank(cbxLevel.Selected.Value))
    )

     

    But this is not searching, I have different search txtName boxes for each field as they are separate

     

    Filter(Search(
     AddColumns(
     'NDT Tracker',
     DisplayName,
     Name.DisplayName,
     AnotherDisplayName,
     Examiner.DisplayName,
     YetAnotherDisplayName,
     Supervisor.DisplayName
     ),
     txtName.Text,
     DisplayName,
     txtExaminer.Text,
     AnotherDisplayName,
     txtSupervisor.Text,
     YetAnotherDisplayName
    ),
    
     (cbxMethod.Selected.Value = Method.Value || IsBlank(cbxMethod.Selected.Value)),
     (cbxLevel.Selected.Value = Level.Value || IsBlank(cbxLevel.Selected.Value))
    )
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @ScablandsKing - does not work that way. If you want to run the Search function against different controls, you will need to chain multiple Search functions together:

     

    Filter(
     Search(
     Search(
     Search(
     AddColumns(
     'NDT Tracker',
     DisplayName,
     Name.DisplayName,
     AnotherDisplayName,
     Examiner.DisplayName,
     YetAnotherDisplayName,
     Supervisor.DisplayName
     ),
     txtName.Text,
     DisplayName
     ),
     txtSupervisor.Text,
     AnotherDisplayName
     ),
     txtExaminer.Text,
     YetAnotherDisplayName
     ),
     Len(cbxMethod.Selected.Value) = 0 || Method.Value = cbxMethod.Selected.Value,
     Len(cbxLevel.Selected.Value) = 0 || Method.Value = cbxLevel.Selected.Value
    )
    

     

    The below returns the same output as above, but in my opinion is more readable:

     

    With(
     {
     _prefiltered_data: Filter(
     'NDT Tracker',
     Len(cbxMethod.Selected.Value) = 0 || Method.Value = cbxMethod.Selected.Value,
     Len(cbxLevel.Selected.Value) = 0 || Level.Value = cbxLevel.Selected.Value
     )
     },
     With(
     {
     _transformed_data: AddColumns(
     _prefiltered_data,
     DisplayName,
     Name.DisplayName,
     AnotherDisplayName,
     Examiner.DisplayName,
     YetAnotherDisplayName,
     Supervisor.DisplayName
     )
     },
     Search(
     Search(
     Search(
     _transformed_data,
     txtName.Text,
     DisplayName
     ),
     txtSupervisor.Text,
     AnotherDisplayName
     ),
     txtExaminer.Text,
     YetAnotherDisplayName
     )
     )
    )
  • ScablandsKing Profile Picture
    201 on at

    Fantastic! Both work like a charm. 

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard