cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ljkeefe
Helper I
Helper I

Gallery not filtering by date

Hi!

I have two galleries on a screen with a small form. The form will be used in the field and the user wants to be able to see previous readings while in the field taking that week's readings. The first gallery works based on a dropdown selected location, this one works fine. For the second gallery, I'm trying to get it to show all locations but Filtered by the date selected in the date picker, 30 days before the day of the reading. The data source is currently a SharePoint list. The column in question is a Date/Time column.

This is what I have in the Items property of Gallery 2. 

Filter(SharePointList,columnnameDate=DateAdd(DateValue1dropdown.SelectedDate,-30,Days))

 The one issue I have had is that I renamed the Date column in SharePoint to SampleDate but the URL still contains Date as the column name. So I have tried 'SampleDate' and Date and neither works. 

I've also tried this:

SortByColumns(Filter(SharePointList,column nameDate=DateAdd(DateValue1dropdown.SelectedDate,-30,Days)),"Date",Descending)

 The gallery is just blank. If I try just the SortbyColumns, the gallery is populated but only with the most recent entries that is not dictated by the date in the dropdown. 

I've tried solutions from the following post without success:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-gallery-by-date/m-p/668261#M213197

https://powerusers.microsoft.com/t5/Building-Power-Apps/Filter-gallery-of-Sharepoint-list-by-date/m-...

I've watched this YouTube video from Reza Dorrani without success as well.

https://www.youtube.com/watch?v=eCMuXPI1Qok

 

It feels like such a simple solution so it's quite frustrating that I can't seem to find it.

Thank you!

Linda

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@ljkeefe 

Your filter is very specific.  It is stating that ONLY rows that have a date that is equal to the selected date minus 30 days.  So that will give you only those rows - if any.

Is this what you want?  Are your records that specific to the date?

 

If it is that you want records that are OLDER than 30 days, then change your formula to the following:

SortByColumns(
    Filter(SharePointList,
        SampleDate <= DateAdd(DateValue1dropdown.SelectedDate,-30,Days)
    ),
    "Date",
    Descending
)

 

Note: when you change the name of a column in SharePoint it never changes that internal name of the column.  It will always be the same name.  When you change the name, you're just changing the display name of the column.

Most, but not all, functions in PowerApps will honor the display name.  Filter will.  SortByColumns will not.

So, for the column name in the Filter, you can use the real name (the internal name) or the renamed display name.  For the SortByColumns, you'll need to specify the real internal name.

 

So in the above formula, it is filtering and sorting by the same column as it should.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@ljkeefe 

Your filter is very specific.  It is stating that ONLY rows that have a date that is equal to the selected date minus 30 days.  So that will give you only those rows - if any.

Is this what you want?  Are your records that specific to the date?

 

If it is that you want records that are OLDER than 30 days, then change your formula to the following:

SortByColumns(
    Filter(SharePointList,
        SampleDate <= DateAdd(DateValue1dropdown.SelectedDate,-30,Days)
    ),
    "Date",
    Descending
)

 

Note: when you change the name of a column in SharePoint it never changes that internal name of the column.  It will always be the same name.  When you change the name, you're just changing the display name of the column.

Most, but not all, functions in PowerApps will honor the display name.  Filter will.  SortByColumns will not.

So, for the column name in the Filter, you can use the real name (the internal name) or the renamed display name.  For the SortByColumns, you'll need to specify the real internal name.

 

So in the above formula, it is filtering and sorting by the same column as it should.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

@RandyHayes Thank you so much! I knew it was going to be something small that I was missing. I am looking for records from the date selected up to 30 days in the past. I just changed the <= to >= and it works perfectly.

Thank you for explaining the SharePoint column name vs. PowerApps name. It's very helpful.

RandyHayes
Super User
Super User

@ljkeefe 

Ah got ya....so within the past 30 days.  Yes, you chose the right operator then.

 

Happy to help and explain things.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,623)