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

Sort/Search Gallery By Date

Need help with some filters:

 

kdillon_0-1618596341338.png

 

I have an app that logs the user logging the data into a microsoft list, along with the date and location. Currently the gallery sorts/searches by the email address of the user. I want to change this to the date. I've tried searching and found some solutions but I'm not really following the code part. 

 

Any help would be appreciated


Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@kdillon 

You can type a date in a DatePicker!

 

So, sorting is not a concern if the person enters a date, only when there is no date selected.

 

So then your formula on the Items property should be:

SortByColumns(
    Filter('Daily Patient Stats', 
        IsBlank(yourDatePicker.SelectedDate) || yourDatePicker.SelectedDate=yourDateColumn)
    ),
    "yourDateColumn",
    If(Coalesce(SortDescending1, true), Descending, Ascending)
)
_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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

5 REPLIES 5
RandyHayes
Super User
Super User

@kdillon 

Are you planning on having the user type in a date to search or are you going to supply a date picker for searching?

Currently you just have a text input.

 

Also, the logic is not making sense as to what you are asking for.  If the user searches for a date, then what do you want to sort by...it will all be the same date??

 

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes 

 

Thanks for replying. I wanted them to be able to type the date - i personally find it quicker. 


In the default gallery if you leave the search blank you can hit the sort button on top. This currently just sorts by the Title which I guess is the email address in this case. I want it to sort the date so the newest date is always on top. 

RandyHayes
Super User
Super User

@kdillon 

You can type a date in a DatePicker!

 

So, sorting is not a concern if the person enters a date, only when there is no date selected.

 

So then your formula on the Items property should be:

SortByColumns(
    Filter('Daily Patient Stats', 
        IsBlank(yourDatePicker.SelectedDate) || yourDatePicker.SelectedDate=yourDateColumn)
    ),
    "yourDateColumn",
    If(Coalesce(SortDescending1, true), Descending, Ascending)
)
_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes 

 

Thanks Randy! 

This worked I just had to add a ( before the second yourDatePicker - figured I'd add that in case someone finds this in the future. 

RandyHayes
Super User
Super User

@kdillon 

Oops, sorry about that.

Actually, the paren should be before that entire line:

SortByColumns(
    Filter('Daily Patient Stats', 
        (IsBlank(yourDatePicker.SelectedDate) || yourDatePicker.SelectedDate=yourDateColumn)
    ),
    "yourDateColumn",
    If(Coalesce(SortDescending1, true), Descending, Ascending)
)
_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,336)