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 III
Super User III

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 II
Super User II

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 III
Super User III

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 II
Super User II

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,811)