Filter by Date Range

In this tutorial we will give the simple code to use if you are looking to filter your PowerApps gallery by date range, where the user will select the specific dates from a DatePicker control.

Steps

Insert 2 x DatePicker input controls to your screen. DatePicker1 (Start Date) and DatrePicker2 (End Date)

Select the gallery and apply the code below on itsĀ ItemsĀ property as:

Items = Filter(
    'Asset Database',
    'Apply Date' >= DatePicker1.SelectedDate,
    'Apply Date' <= DatePicker2.SelectedDate
)

OR

Items = Filter(
    'Asset Database',
    ('Apply Date' >= DatePicker1.SelectedDate) && ('Apply Date' <= DatePicker2.SelectedDate)
)

Only Filter when dates are selected.

When filtering a gallery by multiple items and sometimes the date fields may need to be blank or by default need to be blank when the gallery is loaded to display all items.

This is how I would do this –

Items = Filter(
    'Asset Dattabase',
(If(IsBlank(DatePicker1.SelectedDate),IsBlank(DatePicker2.SelectedDate), Date >= DatePicker1.SelectedDate && Date <= DatePicker2.SelectedDate, true))

Leave a Reply

Your email address will not be published. Required fields are marked *