Power Apps  

Understanding Lookup() and Filter() function in PowerApps

When working with data in PowerApps, two functions you will use very often are Lookup() and Filter(). Both functions help you find data from a collection or data source, but they are used for different purposes.

Many beginners get confused about when to use Lookup() and when to use Filter(). In this article, we will understand both functions in a very simple way with examples.

For demonstration, we will use a dummy collection. In your real application, you can use the same formulas with SharePoint or Dataverse.

Step 1 - Create a Dummy Collection

Add the following code in your App OnStart or Screen OnVisible property:

ClearCollect(
    colEmployees,
    [
        {ID: 1, Name: "Amit", Department: "IT"},
        {ID: 2, Name: "Neha", Department: "HR"},
        {ID: 3, Name: "Raj", Department: "IT"}
    ]
)

This will create a sample employee collection with three records.

Basic Idea

The main difference is very simple:

  • Lookup() - Returns only one record (first matching record)

  • Filter() - Returns all matching records

You can remember it like this:

  • Need one result - Use Lookup()

  • Need multiple results - Use Filter()

What is Lookup()?

The Lookup() function is used when you want to find a single record from a table or data source.

It checks the condition and returns the first matching record only.

Syntax

Lookup(DataSource, Condition)

Example

Lookup(colEmployees, Department = "IT")

This will return only Amit record even though Raj is also in IT, Lookup() stops searching after finding the first match.

Where to Use Lookup()

Lookup() is useful when:

  • You need details of one employee

  • You want to get one selected record

  • You want to fetch a single value like Email, ID, or Name

  • You are searching using unique values like Employee ID

What is Filter()?

The Filter() function is used when you want to get multiple records that match a condition.

Instead of stopping at the first match, Filter() returns all matching records.

Syntax

Filter(DataSource, Condition)

Example

Filter(colEmployees, Department = "IT")

Here, both Amit and Raj are returned because both belong to the IT department.

Where to Use Filter()

Filter() is useful when:

  • You want to show multiple records in a gallery

  • You need to filter employees department-wise

  • You want to search records

  • You need all matching data instead of one record

Key Difference

FeatureLookup()Filter()
ResultSingle recordMultiple records
Matching ResultFirst match onlyAll matching records
Output typeRecord or valueTable

Important Point to Remember

One common mistake beginners make is using Lookup() inside galleries.

  • Use Filter() for galleries because galleries need multiple records.

  • Use Lookup() when showing details of a selected item.

Final Thought

In this article, we used a dummy collection (colEmployees) to make the concept easy to understand. In your actual PowerApps application, you can use the same formulas with SharePoint, Dataverse, SQL, or any other data source.

Once you understand the difference between these two functions, working with data in PowerApps becomes much easier.