<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ajith Kumar</title>
    <description>The latest articles on DEV Community by Ajith Kumar (@ajith_kumar_powerdev).</description>
    <link>https://dev.to/ajith_kumar_powerdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4026601%2F80d356da-d746-4859-a2f2-1104ad02c42b.jpg</url>
      <title>DEV Community: Ajith Kumar</title>
      <link>https://dev.to/ajith_kumar_powerdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ajith_kumar_powerdev"/>
    <language>en</language>
    <item>
      <title>Avoid Delegation Warnings When Using If() Inside Filter() in Power Apps</title>
      <dc:creator>Ajith Kumar</dc:creator>
      <pubDate>Mon, 13 Jul 2026 03:42:08 +0000</pubDate>
      <link>https://dev.to/ajith_kumar_powerdev/avoid-delegation-warnings-when-using-if-inside-filter-in-power-apps-229m</link>
      <guid>https://dev.to/ajith_kumar_powerdev/avoid-delegation-warnings-when-using-if-inside-filter-in-power-apps-229m</guid>
      <description>&lt;p&gt;Instead of placing the conditional logic inside the filter predicate, move the decision-making outside and apply separate Filter() statements.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;If(&lt;br&gt;
    !IsBlank(DatePicker.SelectedDate),&lt;br&gt;
    Filter(dataSource, Created &amp;lt;= Today() - 15),&lt;br&gt;
    Filter(dataSource, Created &amp;lt;= DatePicker.SelectedDate)&lt;br&gt;
)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Each branch contains a simple Filter() expression.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The filter condition remains straightforward and delegable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Power Apps can translate each query more effectively for supported data sources.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Better Approach 2: Precompute the Value and Then Filter
&lt;/h2&gt;

&lt;p&gt;Another clean approach is to calculate the date value first and store it in a variable.&lt;/p&gt;

&lt;p&gt;`Set(&lt;br&gt;
    varCutoffDate,&lt;br&gt;
    If(&lt;br&gt;
        !IsBlank(DatePicker.SelectedDate),&lt;br&gt;
        Today() - 15,&lt;br&gt;
        DatePicker.SelectedDate&lt;br&gt;
    )&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;Filter(&lt;br&gt;
    dataSource,&lt;br&gt;
    Created &amp;lt;= varCutoffDate&lt;br&gt;
)`&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The If() function executes once outside the query.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Filter() predicate remains a simple comparison.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The variable can be reused elsewhere in the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The formula is easier to read and maintain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Should You Use This Pattern?
&lt;/h2&gt;

&lt;p&gt;This approach is particularly useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Working with large SharePoint lists.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using SQL Server or other delegable data sources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reusing the calculated value across multiple controls or screens.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In many cases, the variable-based approach is the most maintainable solution because it separates business logic from data filtering logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;p&gt;❌ Avoid using If() (or other non-delegable functions) directly inside Filter().&lt;/p&gt;

&lt;p&gt;✅ Keep the Filter() predicate as a simple, delegable comparison.&lt;/p&gt;

&lt;p&gt;✅ Move conditional logic outside Filter() whenever possible.&lt;/p&gt;

&lt;p&gt;✅ Use an outer If() or a precomputed variable to maintain delegation.&lt;/p&gt;

&lt;p&gt;✅ Verify delegation behavior when working with large datasets.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

</description>
      <category>powerplatform</category>
      <category>powerapps</category>
      <category>delegation</category>
      <category>powerfx</category>
    </item>
  </channel>
</rss>
