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 browse gallery ...
Power Apps
Answered

Search browse gallery based on lookup

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

 

I have the following lookup function in my Browse Gallery which shows the cutomer name rather than the Customer ID.

 

LookUp(Customer, CustomerID= ThisItem.CustomerIDComments, Name)

 

How do i now search or filter the gallery based on the customer name? At the moment its obviously searching by customer ID.

 

SortByColumns(Filter(Comments,StartsWith(CustomerIDComments, TextSearchBox1_1.Text)), "Created", Ascending)

 

Thanks

 

 

Categories:
  • BCLS776 Profile Picture
    8,994 Moderator on at

    Try using AddColumns to add a CustomerName column that you can then search:

    Search(
     SortByColumns(
     Filter(
     AddColumns(Comments, 
     "CustomerName", 
     LookUp(Customer, CustomerID = CustomerIDComments, Name)
     ),
     StartsWith(CustomerIDComments, TextSearchBox1_1.Text)
     ),
     "Created", 
     Ascending
     ),
     SearchString.Text,
     "CustomerName"
    )

    Hope that helps,

    Bryan

     

    (free-typed, so excuse any typos)

     

  • craigmon Profile Picture
    on at

    Thanks for this, howvere I'm getting lots of errors when pasting this in.  I'm actualy trying to pull the name form the customer table not the comment table.  I've tried the below but still getting the same issue

     

    Search( SortByColumns( Filter( AddColumns(Customer, "Name", LookUp(Customer, CustomerID = CustomerIDComments, Name) ), StartsWith(CustomerIDComments, TextSearchBox1_1.Text) ), "Created", Ascending ), SearchString.Text, "Name" )

  • Verified answer
    BCLS776 Profile Picture
    8,994 Moderator on at

    You'll get errors wherever I assumed the name of a column or other control. Carefully examine the LookUp statement to make sure it references the common ID column between the Customer and Comments tables. The LookUp should be looking in the Customer table with the ID from Comments to match the customer record.

     

    Are you trying to search only by customer name, and not ID as well? If so, we could simplify the code to:

    Search(
     SortByColumns(
     AddColumns(Comments, 
     "CustomerName", 
     LookUp(Customer, CustomerID = CustomerIDComments, Name)
     ),
     "Created", 
     Ascending
     ),
     TextSearchBox1_1.Text,
     "CustomerName"
    )

     'If it is still giving you trouble, please reply with screenshots of column names from each table and any errors being thrown by Power Apps.

     

    Bryan

  • craigmon Profile Picture
    on at

    Thank you Bryan, the below is perfect.  Appreciate your help

     

    Search(
     SortByColumns(
     AddColumns(Comments, 
     "CustomerName", 
     LookUp(Customer, CustomerID = CustomerIDComments, Name)
     ),
     "Created", 
     Ascending
     ),
     TextSearchBox1_1.Text,
     "CustomerName"
    )

     

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

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard