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

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

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

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

@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
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,385)