cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kdillon
Regular 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.
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.
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.
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

@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.
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
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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,512)