cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CarlosFigueira
Power Apps
Power Apps

3.21122: Filter behavior change with errors

Summary: Starting in version 3.21122 of Power Apps Studio, if the predicate of a Filter function returns an error, the result of the function will have an error record (before the error was ignored). Only applied for apps with the 'Formula-level error management' feature enabled. We don't expect many apps to be affected, but this is a fundamental change that deserves a longer explanation.

 

More details: As we get closer to changing the error handling feature from experimental to preview, we made a change on how filtering works when the expression that is used to filter the source returns an error. Let's take this example:

 

ClearCollect(
    companies,
    { Company: "AdventureWorks Cycles", Profits: 200000 },
    { Company: "Contoso Ltd.", Profits: 1350000 },
    { Company: "Fourth Coffee", Profits: -150000 },
    { Company: "LitWare Inc", Profits: 400000 },
    { Company: "Woodgrove Bank", Profits: 3500000 })

 

We want to know which companies had profits in the 7+ digits, so we can use an expression like the one below (yes, I know we could use Profits > 1000000, but this is just an example to illustrate the change) in the Items property of a gallery:

 

Filter(companies, Log(Profits) > 6)

 

The Log function can only be used with positive numbers, so evaluating it for the third row of the input will generate an error. The expression returns true for the second (Contoso) and last (Woodgrove) records. Before the change, the error would be ignored, and that record result would not be part of the result:

Post001.png

We believe that (silently) ignoring errors is a bad thing to do. If something is wrong, the maker and/or the user should be notified that this is the case so that they don't operate on faulty data.

 

With the change done in the 3.21122 release, if the predicate used to filter the record returns an error, then the result of the filter will have an error record in that place. The result will have all of the records that satisfy the predicate(s) passed to the Filter function, plus all error records corresponding to those which caused the predicate(s) to return an error.

Post002.png

A little side note: the notification banner for the error is also a new change introduced in this release; for more information see https://aka.ms/powerapps-errornotification.

 

Back to the Filter change. An error record is something that we can reason about. For example, we can change the TemplateFill property of the gallery to check if the entire record that we are displaying is an error, and show something different to the user:

Post002.5.png

We can also check the fields of the record. Any field of an error record will be an error itself, so we can use that to display additional information to the user as well:

Post002.6.png

To go back to the previous behavior, we can "capture" the error in the predicate itself, using the IfError function - this way the maker is being explicit in handling the error.

Post003.png

Hopefully this helps understanding this new concept that has been added. We will have more detailed information in the official documentation when this release is deployed worldwide. As usual, we want your feedback! Let us know if you have any questions, concerns, suggestions or bug reports on the error handling feature!

 

0 REPLIES 0

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,503)