Power Apps Lookup function allows you to search for specific records in a data source—like a SharePoint list—and retrieve targeted information.
In this tutorial, we’ll walk through how to use the Lookup function effectively, including conditional queries and calculations.
What Is the Lookup Function?
The Lookup
function in Power Apps is used to search a data source and return a single record that matches a specified condition.
It’s ideal for retrieving specific fields from a record, such as a product name or price, based on user input.
Syntax:
Lookup(DataSource, Condition, Result)
- DataSource: The name of your data source (e.g., a SharePoint list)
- Condition: The criteria used to find the record
- Result: The field or calculation to return from the matched record
Step-by-Step: Building a Lookup App
1. Connect to SharePoint
- Go to Add Data in Power Apps
- Search for SharePoint
- Connect to your SharePoint site and select the Products list
2. Design the Interface
- Add a Text Input for price (
TextInputPrice
) - Add a Label to display the product name
- Add another Text Input for quantity (
TextInputQuantity
) - Add a Label to display the total cost
Basic Lookup: Find Product by Price
To find a product based on its price, use the following formula in the label:
Lookup(Products, Price = Value(TextInputPrice.Text), Product)
If the price exists in the list, the product name will be displayed. If not, the label remains blank.
Advanced Lookup: Multiple Conditions
To find a product with a specific price and quantity:
Lookup(
Products,
Price = Value(TextInputPrice.Text) && Quantity = Value(TextInputQuantity.Text),
Product
)
Alternatively, use ||
(OR) to match either condition:
Lookup(
Products,
Price = Value(TextInputPrice.Text) || Quantity = Value(TextInputQuantity.Text),
Product
)
Calculated Lookup: Total Price
To calculate the total cost (price × quantity) of a matched product:
Lookup(
Products,
Price = Value(TextInputPrice.Text) && Quantity = Value(TextInputQuantity.Text),
Price * Quantity
)
Important Behavior: First Match Only
If multiple records match the condition, Lookup
will return only the first record found in the data source. To handle multiple matches or display a list of matches, use the Filter
function instead.
Summary
The Power Apps Lookup
function is a versatile tool for:
- Retrieving specific fields from a SharePoint list
- Applying multiple conditions
- Performing calculations on matched records
Whether you’re building a product catalog, inventory tracker, or pricing calculator, mastering Lookup
will help you create smarter, more dynamic apps.
Leave a Comment