cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Filter SharePoint list on Date value not working (Date column works like text?)

So, I have a SharePoint list with a Date column (no time) and in PowerApps I have the built in Date Picker to select a date and then in a gallery I want to show all list items for the selected date.

 

When I click a date in the date picker we set the date like this:

 

Set(_dateSelected, DateAdd(_firstDayInView, ThisItem.Value, Days))

 

 

This is all according to the default date picker set up, I have not changed anything.

 

The date column in my SharePoint list is simply called "Date" and is of date type:

Skärmklipp.JPG

 

Now, in my gallery I should be able to filter the Date column like this:

 

Filter(Reports, Date=_dateSelected)

 

 

However, this gives the following error:

Skärmklipp.JPG

(note the date format "yyyy-mm-dd")

 

If I convert the date to a text string the filtering suddenly works:

 

Filter(Reports, Date=Text(_dateSelected, "yyyy-mm-dd"))

 

 

It works, but PowerApps says they are of different types:

Skärmklipp.JPG 

 

...and when the users log in to the app they get this:

Skärmklipp.JPG

 

I've tried multiple work arounds, for example I created a calculated text column that converts the date column to a string in the format of "yyyy-mm-dd", then I try to filter on this column in PowerApps with a text version:

 

Filter(Reports, 'Date (Text)'=Text(_dateSelected, "yyyy-mm-dd"))

 

 

Then I get a delegation warning instead, which I shouldn't get on a text column:

Skärmklipp.JPG

 

So, what am I doing wrong when I'm filtering SharePoint for dates? Should I somehow convert the format of the date to make it work?

 

In SharePoint the dates look like this (at least for my user): "mm/dd/yyyy". If I put the _dateSelected into a label it shows the same format. However, in the filtering you can clearly see it tries to filter with "yyyy-mm-dd" (as I noted earlier).

 

I'm not sure how to solve this, I've tried every possible solution I could come up with and find through searching.

 

Thanks in advance!

4 REPLIES 4
Super User III
Super User III

Hi @aldenniklas ,

I am assuming you want to filter a gallery from a DatePicker called _dateselected.

Firstly, Date queries are not delegable - there are workarounds, but I will deal with this initially on the basis you can collect with a delegable query a list of records less than 2000 items - I will call this colReports. You should rename the SharePoint field you call Date to something like ReportDate.

The Items property of the gallery would be

Filter(
   colReports,
   ReportDate = _dateselected.SelectedDate
)

 Please let me know if this suits what you are wanting to achieve.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Thank you for the suggestion!

Why would you rename "Date" to "ReportDate"?

I cannot find a .SelectedDate for the _dateselected.
This is how _dateSelected is set:

Set(_dateSelected, DateAdd(_firstDayInView, ThisItem.Value, Days))
Super User II
Super User II

@aldenniklas 

I think your formula that creates _dateSelected might be the issue?

 

- how is _firstDayInView created or where does it come from

- is ThisItem.Value a number, not a Date?

 

As a tip, your should avoid calling a column 'Date'  because there's also a function called 'Date'. In practivce you should avoid naming any columns the same as a function. It can cause issues but I'm unsure if it is in this instance? You could try:

 

- using disambiguation to reference date column ie in your Filter use [@Date], this may work

- create a new SP column to hold your date, just use a different name. I haven't had a lot of success changing SP column names hence why I suggest creating a new one. I usually hide the old one because deleing causes issues as well ...

 

 

Hi @aldenniklas ,

Confirming the well set out information provided by @Eelman , you should not use "reserved" words (like the name of a function or control) as field or variable names. There are many reasons, one being there may be place you use them in the same context and PowerApps will not know how to interpret the command (do you want the field or a date function).

You mentioned in your post that you were filtering from a DatePicker control and I assumed the name of this was _dateSelected, in which case the date to be filtered would be _dateSelected.SelectedDate.

Now I see the formula below. what is ThisItem.Value and _firstDayInView?

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,427)