cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tapesh
Post Prodigy
Post Prodigy

Sort Items based on Date

Hi 

Experts im trying to sort the items based on name if entered and when they select the sortDecending1 button the items should sort based in the recent date order.  i.e from new to old and when deselected the sort button gallery items so be normal as old to new.

 

I do not know if im doing it correctly or not the below code is correct or not. Can anyone help me, please? if m doing wrong and what part im doing ...

 

Thanks, experts

ON Items property of Gallery:   also with the below formula im getting the delegation warning

 

Tapesh_0-1599644372555.png

When I used the above formula or code 

 

Im getting an error. as below  

Tapesh_0-1599645109881.png

 

 
 

 

 

Please see: I have converted date time to different formate using 

ON text property :

 

 

Text(ThisItem.Created, "[$-en-US]d, mmmm yyyy")

 

 

 

Whereas initial it was just simple Datetime Formate 

Tapesh_0-1599481013416.png

However, the error does remain the same. I.e. unable to sort items on date order ascending or descending.

 

 

Any help Experts Thanks. 

Has to raise this query again as I did not get any feedback on my last one. 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Tapesh 

I'm not completely sure of your formula as you mention sorting by date, but it appears to be sorting by title.

If you want to sort by the Created date, then you can consider using this formula:

SortByColumns(
    Filter(
        'Petty Cash & GL Code' ,
        (StatusResult = "All" || Status = StatusResult) &&
        (SearchBox.Text = "" || StartsWith('Name (Title)', SearchBox.Text))
    ),
    "Created",
    If(SortDescending1, Descending, Ascending)
)    

 

This should give you results sorted by Created date.

 

Also, for future reference, if you want to sort by the Text version of a date, you should have your date in a yyyymmdd format.  Otherwise your sorting will be incorrect.

 

I hope this is helpful for you.

 

 

_____________________________________________________________________________________
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

1 REPLY 1
RandyHayes
Super User
Super User

@Tapesh 

I'm not completely sure of your formula as you mention sorting by date, but it appears to be sorting by title.

If you want to sort by the Created date, then you can consider using this formula:

SortByColumns(
    Filter(
        'Petty Cash & GL Code' ,
        (StatusResult = "All" || Status = StatusResult) &&
        (SearchBox.Text = "" || StartsWith('Name (Title)', SearchBox.Text))
    ),
    "Created",
    If(SortDescending1, Descending, Ascending)
)    

 

This should give you results sorted by Created date.

 

Also, for future reference, if you want to sort by the Text version of a date, you should have your date in a yyyymmdd format.  Otherwise your sorting will be incorrect.

 

I hope this is helpful for you.

 

 

_____________________________________________________________________________________
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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,265)