PowerApps (LookUp an Item)

Phone Book

For those of you that were around before smartphones and the internet were a thing, I am sure you remember the thick phonebooks that were delivered to our door steps. I remember thumbing through the yellow or white pages looking for a name to get a phone number or address. Those days were fun (sarcasm).

In this blog post I will be going over what the LookUp function is in PowerApps and how to use it. The LookUp function is one that every PowerApps developer should know how to use and when to use it. Luckily, the LookUp function is not as painful as using the antiquated phonebook.

According to the Microsoft Documentation, the LookUp function looks for the first record in a data source that satisfies a condition which returns a boolean. An example will help to illustrate this. Let’s say I have a SharePoint list with several items (can also be considered records) and they contain information about all the fast food places in the area (McDonald, Subway, Wendy’s, etc.). If I use the LookUp function, it would retrieve the first ‘Subway’ in the SharePoint list regardless of how many Subway locations are in the list. Here’s my ‘Fast Food’ list

Fast Food
NameStreet
McDonald7th st
SubwayABC Avenue
Wendy’s11th St
Subway9th St
Hardee’sKinte St

Here’s how to use the LookUp function to perform the same ‘Subway’ search in PowerApps.
The LookUp function has 3 parameters. The first 2 are required and the last is optional.

LookUp(datasource, formula, reduction formula)

Example:

LookUp('Fast Food',Name="Subway",Street)

returns
ABC Avenue

LookUp(datasource, formula)

returns

SubwayABC Avenue

When the optional parameter is used, just a single value from the record is returned. When the optional parameter is not used, the whole record or item is returned.

Here’s a practical use of the LookUp function. Let’s say you have an application that requires Admin access to parts that a regular user shouldn’t have access to. You can have an access control list, which has a list of Admin users.

AdminAccess
John DoeManager
Sue DoeCTO
Bobby LouDirector

If in your app, you wanted only the Sue Doe, CTO, to see certain information. You can use a LookUp to find Sue Doe. Here’s how:

LookUp(Admins, Admin = "Sue Doe")

The above translates to, look in the Admin list where the Admin column is equal to “Sue Doe”.

I hope this is helpful.

Happy PowerApping!!!

Power Platform PowerApps SharePoint SharePoint Online

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: