cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wstone
New Member

Filter Galley by date

I've searched the web and this forum and can't find what I need.  I'm sure it's simple but I can't figure It out.

 

I have a galley that I want to sort by Today's date.  I only want today's date entries to show.  It's connected to an SQL database with a date column.

 

This is the code that is in by default when I chose SQL 

 

SortByColumns(Search([@'[dbo].[dailyLog]'], TextSearchBox1.Text, "Address","Twp","PlumbingContractor","PermitNum","Type"), "Date", If(SortDescending1, Descending, Ascending))

 

I've tried modifying it all kinds of different ways but I'm missing something.  I want the search bar to work as well.  

2 ACCEPTED SOLUTIONS

Accepted Solutions
eka24
Super User
Super User

Try

SortByColumns(Filter(Search([@'[dbo].[dailyLog]'], TextSearchBox1.Text, "Address","Twp","PlumbingContractor","PermitNum","Type"),DateColumn=Today()), "Date", If(SortDescending1, Descending, Ascending))

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

View solution in original post

Drrickryp
Super User
Super User

Hi @wstone 

If you want only the current date items to show, you need to include a filter in your formula.

 

SortByColumns(Search(Filter([@'[dbo].[dailyLog]'],Date=Today()), TextSearchBox1.Text, "Address","Twp","PlumbingContractor","PermitNum","Type"), "Date", If(SortDescending1, Descending, Ascending))

 

The result should have only items with a Date column = to the current date.  Given that, your sort doesn't make sense since all of the items will only have the current date.  You may wish to sort the list on some other column like "PermitNum" or "PlumbingContractor".  FYI, PowerApps formulas work from the "inside out".  So in the case of my solution the dailylog is filtered first, then searched and finally sorted.  In the above solution by @eka24 , the daily log is searched first, then filtered and then sorted.  The final result should be the same.  

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

Try

SortByColumns(Filter(Search([@'[dbo].[dailyLog]'], TextSearchBox1.Text, "Address","Twp","PlumbingContractor","PermitNum","Type"),DateColumn=Today()), "Date", If(SortDescending1, Descending, Ascending))

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

View solution in original post

Drrickryp
Super User
Super User

Hi @wstone 

If you want only the current date items to show, you need to include a filter in your formula.

 

SortByColumns(Search(Filter([@'[dbo].[dailyLog]'],Date=Today()), TextSearchBox1.Text, "Address","Twp","PlumbingContractor","PermitNum","Type"), "Date", If(SortDescending1, Descending, Ascending))

 

The result should have only items with a Date column = to the current date.  Given that, your sort doesn't make sense since all of the items will only have the current date.  You may wish to sort the list on some other column like "PermitNum" or "PlumbingContractor".  FYI, PowerApps formulas work from the "inside out".  So in the case of my solution the dailylog is filtered first, then searched and finally sorted.  In the above solution by @eka24 , the daily log is searched first, then filtered and then sorted.  The final result should be the same.  

View solution in original post

wstone
New Member

I swear I tried variations of those.  Worked great though!

 

Thanks everyone!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,829)