Post

#PowerPlatformTip 64: 'Comparing Lookup vs. First(Filter)'

#PowerPlatformTip 64: 'Comparing Lookup vs. First(Filter)'

TL;DR: LookUp(Source, Condition) and First(Filter(Source, Condition)) return the same first matching record, and all three functions are delegable. Pick one pattern for consistency, and know the two real differences: LookUp() can return a single value with its third argument, First(Filter()) lets you sort before you take the first record.

💡 Challenge

In Power Apps, when you need to retrieve the first record that meets certain criteria, you have two options, LookUp() and First(Filter()), which can cause confusion over which to use.

✅ Solution

Pick one consistent pattern. Using First(Filter(Source, Condition)) throughout keeps your code simple and uniform, and it extends naturally when you need sorting. Use LookUp() where its third argument saves you a step.

🔧 How It’s Done

1. Identify your criteria

🔸 Determine the data source (Source) and the filter condition.

🔸 Write Filter(Source, Condition) to narrow down records.

2. Retrieve the first match

🔸 Wrap the filter in First():

First( Filter( Source, Condition ) )

🔸 It returns the same record as:

LookUp( Source, Condition )

🔸 Both return Blank() if nothing matches.

3. Know where they differ

🔸 “The latest” or “the highest”: LookUp() has no sort order. To get the most recent matching record, sort before you take the first one:

First( Sort( Filter( Orders, Customer = "Contoso" ), Created, SortOrder.Descending ) )

🔸 Several conditions: Filter() takes several conditions as separate arguments, Filter(Orders, Status = "Open", Amount > 100). In LookUp() you combine them with &&.

🔸 A single value: LookUp(Source, Condition, Column) returns the value directly, see Tip 63.

4. Standardize across your app

🔸 Decide on one pattern for “first matching record” and use it in every screen.

🔸 Maintaining a single pattern improves readability and eases future updates.

🎉 Result

You now have a uniform approach to fetching the first matching record, making your Power Apps formulas more consistent and easier to read. Because Filter, First and LookUp are all on the list of delegable functions, the choice doesn’t force a local scan of your data.

🌟 Key Advantages

🔸 Consistent coding pattern throughout your app

🔸 Improved readability and maintainability

🔸 Delegable either way, as long as the condition itself is delegable for your data source

🔸 First(Filter()) grows into First(Sort(Filter())) without rewriting

🎥 Video Tutorial

🛠️ FAQ

1. What’s the difference between LookUp() and First(Filter())?

Both return the first record that matches the condition, or Blank() if none does. LookUp() can also evaluate a formula on that record (third argument), First(Filter()) can be combined with Sort().

2. When might I still use LookUp()?

When you only need one column or a calculated value from the match, LookUp(Source, Condition, Column) is shorter. Tip 63 shows the variants.

3. Does switching to First(Filter()) impact delegation?

No. Filter, First and LookUp are delegable functions. Delegation depends on the condition: if it uses a non-delegable function for your data source, both forms only look at the first records up to the Data row limit, and Power Apps shows a delegation warning.

🔸 #PowerPlatformTip 63: ‘Mastering the Lookup Function’ - the direct-column Lookup(Source, Condition, COLUMN) syntax worth knowing before you standardize on one pattern.

🔸 #PowerPlatformTip 23: ‘Filter Blank’ - a common addition to the Filter() half of First(Filter()).

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.