In this blog post , we will discuss the PowerApps lookup function, what is the lookup function, how to use?, and give some examples about the lookup function in PowerApps, such as the LookUp function with single condition, the LookUp function with multiple condition , the LookUp function with lookup column, and so on.
What is PowerApps lookup function?
LookUp function in PowerApps finds the first record in a table that matches a formula. LookUp can be used to find a single record that matches one or more criteria.
- If the Lookup function matches the formula, either it returns single row from the table or a single value.
What happens if no record is found in power apps lookup?
If no record is found, Power apps lookup function returns blank.
What is the difference between the lookup and filter functions?
- The Filter function searches a table for records that match a formula. You can identify a set of records using Filter and eliminate any that don’t meet one or more criteria. This is similar to using the Filter in a SharePoint View or Excel to return a number of records from the list that satisfy one or more criteria and toss out any that don’t.
- The LookUp function locates the first matching record in a table so to locate a single record that meets one or more requirements, use LookUp.
In conclusion you can use the The LookUp function to find the first record in a table that satisfies a formula. the LookUp find a single record that matches one or more criteria.
Which function should I use Filter, Search, Lookup?
LookUp :Use the PowerApps LookUp feature to find a single record according to a specific condition.
Filter : Use the PowerApps Filter function to find multiple records that meet a set of criteria.
Search : Use the PowerApps Search function when searching for objects where a search term is contained in a column.
Power Apps Lookup Function Syntax
LookUp(Table*, Formula [, *ReductionFormula* ] )
or we can referee to the syntax same as you will find in the formula in PowerApps
LookUp(Source,Condition,Result)
Table – This is required. the table name to be searched.
Formula – This is required. The formula used to evaluate each record in the table.
The function returns the first record with the value true. Columns within the table can be referenced.
ReductionFormula – This is Optional This formula is applied to the discovered record and then reduces it to a single value. Columns within the table can be referenced. If this parameter is not specified, the function returns the entire record from the table.
Example: this will search the source Weather and get the first record that has temperature= 60
LookUp(Weather, Temperature = 60)
PowerApps lookup function examples
Now we will list some Lookup examples to show how to use the lookup function with single or multiple conditions. We use the following employee hierarchy SharePoint list for our examples
PowerApps lookup function single condition
In this example we will show how to use the lookup function in Power Apps with a single condition.
EX: how to get the record for the CFO from the list.
LookUp('Employee Hierarchy',Role.Value="CFO")
Employee Hierarchy is the SharePoint list name “the Data source”.
Role.Value=”CFO” is the formula “the condition that we want to achieve”
the Output will be the first record that will match the condition where the role is equal to CFO ,
PowerApps lookup function with lookup column or person column
The ‘Employee Name’ in the list is person column, so lets learn how to get the properties of that column as a result of the PowerApps LookUp function.
You can use the record to extract information from it, or whatever you will do. the bellow formula will display the DisplayName of the employee returned by the lookup function, the output will be “Omr Mohamed“
LookUp('Employee Hierarchy',Role.Value="CFO").'Employee Name'.DisplayName
Or you can set a variable to hold the record
Set(varCEO,LookUp('Employee Hierarchy',Role.Value="CFO"))
You can provide a column name to your lookup function, if you want a specific column
LookUp('Employee Hierarchy',Role.Value="CFO" ,'Employee Name'.DisplayName)
PowerApps lookup function multiple conditions
You can also apply multiple condition in the lookup formula and it will return the record that matches these conditions. In the beloow code we will lookup for the employee with role Lina maneger and in Department Dept 1
LookUp('Employee Hierarchy',Role.Value="line Manager" && Department.Value="Dept 1")
the result will be Hamza Mohamed that is a line manager in Dept 1
You can provide a column to your lookup function in the third argument as the following ,
LookUp('Employee Hierarchy',Role.Value="line Manager" && Department.Value="Dept 1",'Employee Name'.DisplayName)
Conclusion
In conclusion you can use the The LookUp function to find the first record in a table that satisfies a formula. the LookUp find a single record that matches one or more criteria.
See Also
- Nested Collection In PowerApps :3 Level
- PowerApps Parse JSON Examples
- Tabbed Form In PowerApps
- Show Internet Base Time In PowerApps |
- Canvas App Collections
- How To Overcome PowerApps Delegation Limit?
- How To Use PowerApps Value Function?
- How To Use Power Automate?
- PowerApps Print Function, Forms, And Scrollable Galleries
- PowerApps Validation Examples On/before Submitting
- Share PowerApps With External Users / Guest Users
Join us
- Subscribe to Power Platform Geeks YouTube channel.
- Register to Saudi Arabia Power Platform User Group.
Need Help
- Have a related question? Please ask it at deBUG.to Community.