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 / Lookup not working pro...
Power Apps
Answered

Lookup not working properly in ForAll?

(0) ShareShare
ReportReport
Posted on by 27

Hello everyone, I am fairly new in PowerApps so now, I don't know it's limitation or I just haven't found the solution.

I have a simple app that I want to do, basically it's a bulk upload tool of salary. My idea was to put it in a delimited text, and then delimit it in a gallery.

 

tundaka_0-1648042828137.png

 

Here's my code in the upload button :

 

 

 

ForAll(
Gallery2.AllItems,
Patch(
'Salary Series',
Defaults('Salary Series'),
{'Employee ID':
LookUp(
Employees,
'Employee ID' = txt_employeeID.Text
)
},
{Value: Value(txt_Value.Text)}
)
)

 

 

 

 

tundaka_2-1648042990979.png

 

it works, but it doesn't lookup the employee id, it only does it in the first row. (Employee ID is a Lookup column to Employees table). Hopefully someone could help me.

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    ForAll( @RandyHayes  ) Randy is very good at explaining the ForAll loop in PowerApps. Hopefully he can drop by and provide the in depth explanation, but at the simplest level it is being used backwards here

  • Gelos Profile Picture
    457 on at
    ForAll(
    Gallery2.AllItems,
    Patch(
    'Salary Series',
    Defaults('Salary Series'),
    {'Employee ID':
    LookUp(
    Employees,
    'Employee ID' = txt_employeeID.Text,(Give column name of emplyees yout want)
    )
    },
    {Value: Value(txt_Value.Text)}
    )
    )
  • Gelos Profile Picture
    457 on at

    I understand you  fetch employee id for employees  table. Am I correct. If I am correct. that above code will work.

  • tundaka Profile Picture
    27 on at

    Yes, that is correct, I am fetching the employee id from the employee table. But sorry, what do you exactly mean by 

    (Give column name of employees you want)

    any column name or column coming from employee table? 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @tundaka 

    As @TheRobRush mentioned...

    To start, your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  It is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    Your formula given should be the following:

     

    Patch('Salary Series',
     ForAll(Gallery2.AllItems,
     {'Employee ID': LookUp(Employees, 'Employee ID' = txt_employeeID.Text, EmployeeID),
     Value: Value(txt_Value.Text)
     }
     )
    )

     

     

    Now, I am not entirely sure what it is that you want to do with delimiting the text in the Gallery...can you explain more about that?

  • Gelos Profile Picture
    457 on at

    Sorry. I didn't notice properly. randy give the answer try it. It will work

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Gelos 

    Actually noticing that the Lookup is not specifying a value in the formula I provided.  It is corrected above and repeated here for clarity:

    Patch('Salary Series',
     ForAll(Gallery2.AllItems,
     {'Employee ID': LookUp(Employees, 'Employee ID' = txt_employeeID.Text, EmployeeID),
     Value: Value(txt_Value.Text)
     }
     )
    )

    EmployeeID should be replaced with the name of the actual column with the information.

     

    However, there is still the question of delimiting and the purpose thereof.

  • tundaka Profile Picture
    27 on at

    Thank you for clarifying, yes I was actually thinking for the longest time that it works similarly as a For Loop.

     

    The idea behind is we are looking for a solution for the client to bulk upload the employee salary in the easiest way. Some few options we had before was to have an excel file with a live connection, other one is just to teach them directly sql. But we are currently looking at this approach, where they concatenate the employee ID and the salary, paste it in the text box, then delimit, and then upload. 

     

    I tried btw your code, it works, but same result as mine, it only does the look up for the first row. 

    tundaka_0-1648045539250.pngtundaka_1-1648045555008.png

     

  • Gelos Profile Picture
    457 on at

    Hi @RandyHayes  glad to meet you.

    ForAll(
    Gallery2.AllItems,
    Patch(
    'Salary Series',
    Defaults('Salary Series'),
    {'Employee ID':
    LookUp(
    Employees,
    'Employee ID' = txt_employeeID.Text
    )
    },
    {Value: Value(txt_Value.Text)}
    )
    )

    he mentioned {value:value(txt_value.Text)} I thought it is second parameter so I write following code

    ForAll(
    Gallery2.AllItems,
    Patch(
    'Salary Series',
    Defaults('Salary Series'),
    {'Employee ID':
    LookUp(
    Employees,
    'Employee ID' = txt_employeeID.Text,(coulumn of employeeid from employess table)
    )
    },
    {Value: Value(txt_Value.Text)}
    )
    )

    Please tell weather it is correct or not

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @tundaka 

    So, a little confused on the over all design then...

    In your original picture you show a gallery of delimited items, but you are mentioning a text input for this.

    From your picture, is the idea to have the person enter the employee ID into one text input and then the salary in the second, and then for the records created/updated, you want the two combined together with a delimiter?

    Please clarify.

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard