Instead of placing the conditional logic inside the filter predicate, move the decision-making outside and apply separate Filter() statements.
If(
!IsBlank(DatePicker.SelectedDate),
Filter(dataSource, Created <= Today() - 15),
Filter(dataSource, Created <= DatePicker.SelectedDate)
)
Why This Works
Each branch contains a simple Filter() expression.
The filter condition remains straightforward and delegable.
Power Apps can translate each query more effectively for supported data sources.
Better Approach 2: Precompute the Value and Then Filter
Another clean approach is to calculate the date value first and store it in a variable.
`Set(
varCutoffDate,
If(
!IsBlank(DatePicker.SelectedDate),
Today() - 15,
DatePicker.SelectedDate
)
);
Filter(
dataSource,
Created <= varCutoffDate
)`
Why This Works
The If() function executes once outside the query.
The Filter() predicate remains a simple comparison.
The variable can be reused elsewhere in the application.
The formula is easier to read and maintain.
When Should You Use This Pattern?
This approach is particularly useful when:
Working with large SharePoint lists.
Using SQL Server or other delegable data sources.
Reusing the calculated value across multiple controls or screens.
In many cases, the variable-based approach is the most maintainable solution because it separates business logic from data filtering logic.
Key Takeaways
❌ Avoid using If() (or other non-delegable functions) directly inside Filter().
✅ Keep the Filter() predicate as a simple, delegable comparison.
✅ Move conditional logic outside Filter() whenever possible.
✅ Use an outer If() or a precomputed variable to maintain delegation.
✅ Verify delegation behavior when working with large datasets.
Summary
A common cause of delegation warnings in Power Apps is placing conditional logic such as If() directly inside a Filter() function. Although the individual comparisons may be delegable, the combined expression often is not. By moving the decision-making outside the filter or precomputing values in a variable, you can keep your queries delegable, improve performance, and ensure accurate results when working with large data sources.
Top comments (0)