Power Apps Filter Gallery By Date Range Delegation [How to Workaround]

Are you facing any delegation while working with Power Apps Filter Gallery By Date Range? This Power Apps tutorial explains the Power Apps filter gallery by date range delegation.

Also, we will see how to overcome this Power Apps delegation while working with the Power Apps filter gallery by date range.

Here, I have explained two various ways/methods to work with the Power Apps filter gallery by date range delegation. Such as:

Power Apps Filter Gallery By Date Range Delegation

  • For example, I have a Power Apps gallery. While working with the Power Apps filter gallery by date range, I am getting the last 5 days’ records.
  • Also, I faced a delegation warning [Yellow triangle], as in the screenshot below. The warning message appears as “Delegation warning. The highlighted part of this formula might not work correctly on large data sets. The “Add” operation is not supported by this connector.“.
Power Apps Filter Gallery Using Date Range Delegation

Scenario:

  • I have a SharePoint Online list named “Expense Tracker”. This list contains the below fields. Such as:
Column NameData Type
Item This is a Title column with a single line of text. I just renamed it to “Item”
CategoryChoice
Payment DateDate and time
AmountNumber
Power Apps Filter Gallery By Date Range Delegation
  • Then, open the Power Apps canvas app -> Insert a Gallery control [gal_Last5DaysRecords] and set its Items property as:
Items = Filter(
    'Expense Tracker',
    'Payment Date' < (Today() - 5)
)

Where,

  1. Filter() = This Power Apps Filter() function find a set of record that match one or more criteria
  2. ‘Expense Tracker’ = SharePoint Online List
  3. ‘Payment Date’ = SharePoint date field column
  4. <(Today()-5) = Power Apps Today() function finds the current date and ‘-5’ is the number of previous days // You can change the number of days

Refer to the below image:

Power Apps Filter Gallery With Date Range Delegation
  • Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Last 5 Days Records], and provide a delegation warning like below.
Power Apps Gallery Filter Date Range Delegation

To overcome this Power Apps delegation warning, follow the two approaches below. Such as:

  1. By using Power Apps, Variables
  2. By using Power Apps Collection

Method 1: By using Power Apps Variables

We can use Power Apps variables to overcome the Power Apps filter gallery by date range delegation.

Refer to the below screenshot:

How to Power Apps filter a gallery by date range delegation

To achieve the above example, follow the below-mentioned steps.

  • Open the Power Apps canvas app -> Select “App” and set its OnStart property as:
OnStart = Set(
    StartDate,
    Today() - 5
);
Set(
    EndDate,
    Today()
);

Where,

  1. Set() = This function helps us to set a value of a global variable
  2. StartDate, EndDate = Power Apps global variable names
  3. Today() – 5 = This Today() function finds the current date, and ‘-5’ is the number of previous days // You can change the number of days
Power Apps Gallery Filter By Date Range Without Delegation
  • Next, on the Power Apps Screen -> Insert a Gallery control and set its Items property code like below.
Items = Filter(
    'Expense Tracker',
    'Payment Date' > StartDate,
    'Payment Date' <= EndDate
)

Where,

  1. ‘Expense Tracker’ = SharePoint Online List
  2. ‘Payment Date’ = SharePoint Date Field
  3. StartDate, EndDate = Global Variables
How to Filter Power Apps Gallery By Date Range Without Delegation
  • Run OnStart, Save, Publish, and Preview the app. The gallery will display the filtered records, i.e., [Previous 5 Days Records] without Power Apps delegation.
Power Apps filter a gallery by date range delegation

Method 2: By using Power Apps Collection

We can use the Power Apps collection to overcome or fix the Power Apps filter gallery by date range delegation.

Refer to the below image:

Power Apps Collection Filter By Date Range

To do so, follow the below steps. Such as:

  • Open the Power Apps canvas app -> Select “App” object -> Select OnStart and set its property as:
OnStart = ClearCollect(
    colExpenses,
    'Expense Tracker'
)

Where,

  1. colExpenses = Power Apps Collection
  2. ‘Expense Tracker’ = SharePoint Online List
Power Apps Filter Collection By Date Range
  • Next, on the Power Apps Screen -> Insert a Gallery control -> Set its Items property as:
Items = With(
    {
        StartDate: Today()-5,
        EndDate: Today()     
    },
    Filter(
        colExpenses,
        'Payment Date' > StartDate,
        'Payment Date' <= EndDate
    )
)

Where,

  1. With() = This function can help us to evaluate a formula for a single record
  2. StartDate, EndDate = Power Apps scope variables
  3. colExpenses = Power Apps collection
  4. ‘Payment Date’ = Collection date field
Power Apps Collection Filter By Date Range Without Delegation
  • Run OnStart, Save, Publish, and Preview the app. The gallery will display the filtered Collection records, i.e., [Previous 5 Days Records] without Power Apps delegation, as in the screenshot below.
Power Apps Filter Collection By Date Range Without Delegation

These are the two ways/approaches to overcome the Power Apps filter gallery by date range delegation.

Conclusion

You will face a Power Apps delegation warning by date range while working with the Power Apps filter gallery.

Here, from this Power Apps tutorial, we learned in detail information about the Power Apps filter gallery by date range delegation.

Also, we discussed two various ways/methods to work with the Power Apps filter gallery by date range delegation. Such as:

  • By using Power Apps Variables
  • By using Power Apps Collection

Also, you may like some more Power Apps tutorials: