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 / Lookup always return f...
Power Apps
Suggested Answer

Lookup always return first row

(0) ShareShare
ReportReport
Posted on by 151
Hi guys!

Im working in app and i need that when users writing a "Code"  in a field another field search code on gallery and returns value.
 
 


but regardless of the code I write, the lookup always returns the first row of gallery, look:



The field I'm looking for does not exist in the collection that feeds the gallery, it is created directly in the gallery

My formula: 
LookUp(ColPedidosDistinct;ThisRecord.Result = TextInput2.Text;Label8.Text)
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at
    That is the way lookup() is designed to work and there is no way to change it.  If you want a collection of matching records to put in a gallery you should be using filter() instead of lookup()
     
    Filter(ColPedidosDistinct;ThisRecord.Result = TextInput2.Text;Label8.Text)

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Guicord101 Profile Picture
    151 on at
    But I don't want a collection, I would like the lookup to return according to the code the user wrote.

    Example

    If user write "45000005" lookup returns Label8 Where Code = 45000005 
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,414 Super User 2025 Season 2 on at
    Hi,
     
    Apologies I am still confused and you have good stuff in your ask but I am still missing something.
     
    Ahh wait, ok so when they typed in xxxxx2 they should get xxxxx3 back
    and then you typed xxxx3 and it should return xxxx4 back correct?
     
    But then I read and you said 
    If user write "45000005" lookup returns Label8 Where Code = 45000005 
     
    So in the above you should get back the xxxxx6 value right? since 45xxxxx5 has that 45xxx6 code at the end?
     
    Can you please tell me the names of the text boxes from inside the gallery and out, I know you wrote stuff, but please for me do it again
     
    TextBoxName for Column1 - where its like 45xxx2 in your second picture
    TextBoxName for Column3 - where its like 45xxx3 in your second picture (and on the same line as 45xx2)
    TextBoxName for the user to input into
     
    Lastly, you said your lookup keeps giving you back the same row, is the Gallery filled with a Collection or Table? can you please give that name, and the name of the column from within that datasource that you are comparing the users input too. So I want the textboxnames and column name for comparison of the user.
     
    I actually don't understand why its returning you the first row all the time. I actually don't agree with PStork1 on this once, but I could be mentally confusing something.
     
    Imagine I had a Collection/DataSource that populated the Gallery
    in the gallery I have TextBox1, which has ThisItem.Value1
    in the gallery I have TeXtBox2, which has ThisItem.Value2
     
    Then outside I have Textbo3 where someone types 45XXXX2
     
    Assuming the Compared Column is called CompareUserInputToMe I would do
     
    LookUp(DataSource, CompareUserInputToMe = Value(userInput.text)) since it appears to be a number not a string??????? if so then you need to convert it to a number if not please do it this way
     
    LookUp(DataSource, ComparUserInputToMe = userInput.Text)
     
    And I would expect to get back the Record that has the correct Value you need
     
    So inputing 45xxxx5 should give you back the Row in the DataSource that matches and then you can grab the desired value like
     
    LookUp(DataSource, ComparUserInputToMe = userInput.Text).DesiredValue
     
    Which is what you are saying but its not working. Thats why I want all the details laid out for me. again.
     
    Actually now I saw you say its not in the Gallery so honestly I am really confused and the details dont make sense.
     
    How are you showing a Value in the Gallery that isn't in the Collection they typed in?
     
    Are you saying that the Value of TextBox2 in my example, is BLANK, but you want it to be dynamically populated BASED on whatever.. totally confusing
     
    Thanks!

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard