web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filtering gallery betw...
Power Apps
Answered

Filtering gallery between two datepickers

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, 

I am struggling to solve this issue, it is pretty much the final piece of the app, and is frustrating that I cannot solve it. So any help is much appreciated.

 

I am trying to filter a gallery by multiple dropdowns (4)

- Location

- Sub-Location 

- Two DatePickers (Start Date) and (End Date)

- Shift

 

My gallery was filtering fine using the Location and Sub-Location dropdowns, however, I cannot get it to filter based on if the date 'Created' (the automatic Created column in SharePoint Lists) was between the two DatePickers. So the user would select the Start Date, and then the End Date, and then the Gallery would show the relevant data Created ibetween those two dates. Whilst also getting filtered on Location, Sublocation and Shift.

I have tried writing the code as you can see in my attachment, however I am getting the error code on the = sign. 'Invalid argument type: Expecting one of the following: Number, Decimal, Date, Time, DateTime, UntypedObject. 

 

Below is my current code.

Filter('Operations MIR List',
Location = Dropdown_Location_2.Selected.Result,
'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
'Created' = DatePicker_Start_Date.SelectedDate>=DatePicker_End_Date.SelectedDate && DatePicker_Start_Date.SelectedDate<=DatePicker_End_Date.SelectedDate)

 

 

Once this issue is solved, I'd also want it so that on the Shift filter, the options are '-----', Red, Blue, Green, Yellow. When the option '-----' is selected, I'd like the gallery to just show all shifts data. However, I need to solve this datepicker issue first.

 

Any help is much appreciated, thanks.

 

Categories:
  • Verified answer
    NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    HI @Anonymous ,
    Try using below formula - 
    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    ('Created' >= DatePicker_Start_Date.SelectedDate && 'Created' <= DatePicker_End_Date.SelectedDate))


  • Ash13 Profile Picture
    576 on at

    The last part of the filter should be:

    'Created'>=DatePicker_Start_Date.SelectedDate && 'Created'<=DatePicker_End_Date.SelectedDate

     

    For the Shifts dropdown, you want another argument like:

    ... , Dropdown_Shift.Selected.Result = "-----" || Shift=Dropdown_Shift.Selected.Result

    which just returns true if the "-----" is selected, so returns all results

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Ash13 ,

     

    Thanks for replying.

    So where would I put that extra bit about the '-----' in my code, Im not sure where this additional argument would go or how it would look. My current code is:

     

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate)

     

    Also, if I wanted to do the same thing with the 'Sub-Location' dropdown, how would I do this? So for example, a user selects Line 2 Location, but the Sub-Location remains blank ('-----'), then can the gallery search for all of Line 2?

     

    Thanks again

     

  • Ash13 Profile Picture
    576 on at

    Hi @Anonymous 

     

    You should be able to add it in like your other arguments:

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate ,
    Dropdown_Shift.Selected.Result = "-----" || Shift=Dropdown_Shift.Selected.Result)

    (I've guessed the name of the dropdown and SharePoint column so you may need to change them)

    and yes this should work for all dropdowns you want to do this with

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate ,
    Dropdown_Shift.Selected.Result = "-----" || Shift=Dropdown_Shift.Selected.Result,
    Dropdown_SubLocation.Selected.Result= "-----" || SubLocation=Dropdown_SubLocation.Selected.Result
    )
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Ash13 ,

     

    Thanks for sending all that over, I have tried using the code: 

     

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Dropdown_Shift_Incident.Selected.Shift = "-----" || 'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate)

     

    However, as you can see from my attachment, when I select "-----" on the Shift, it does not show all shifts data. So just wondering how I can make it work.

     

    Thank you for all your help so far. 

  • Verified answer
    Ash13 Profile Picture
    576 on at

    Hi @Anonymous 

     

    My apologies - The previous filter condition  ('Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,) needs removing. This should work:

     

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result,
    Dropdown_Shift_Incident.Selected.Shift = "-----" || 'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate)

     

     Same goes for the sub location one if you do that one too, so it would become:

    Filter('Operations MIR List',
    Location = Dropdown_Location_2.Selected.Result,
    'Sub-Location' = Dropdown_Sub_Location_2.Selected.Result || Dropdown_Sub_Location_2.Selected.Result="-----",
    Dropdown_Shift_Incident.Selected.Shift = "-----" || 'Shift of Incident' = Dropdown_Shift_Incident.Selected.Shift,
    Created >=DatePicker_Start_Date.SelectedDate && Created<=DatePicker_End_Date.SelectedDate)

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @Ash13 ,

     

    This code works perfectly, thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard