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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,322)