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.

 

 

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.  

wstone
New Member

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

 

Thanks everyone!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,765)