cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lgillett
Level: Powered On

Sort by date and time

Hello,

 

I am trying to sort my sharepoint list, which is within my powerapp, by time and date to show the nearest date and time first and the furthest last. The list is sorted fine in sharepoint but that does not transfer over when I have added to my powerapp.

 

The attached file, Timetables.jpg, shows an overview of my app.

 

As you can see; there is a random date 20/9/2019 in the middle of the list, there is a date that should technically be displayed first at the bottom of the list and the times are not ordered.

 

The browse gallery formula is: SortByColumns(Filter('Music Timetables', StartsWith('Student Name', TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

The list is called 'Music Timetables' and the columns shown are (in order L-R): Lesson Time, Student, Calculate date Formula, Calculated Time Formulae, Teacher

 

The column that I want to sort by is the first column (ThisItem.'Lesson Time'). When sorted this column will be hidden/invisible and the seperate date and time will be shown (3rd and 4th columns from the left).

 

How would I sort the order of items by this column? I have tried everything that I can think of but with no joy!

 

Sorry if this makes no sense. I can try and explain further if required. Im still new to powerapps!

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Sort by date and time

Hey @lgillett 

 

In that case, you can update the formula as:
 
Sort(Filter('Music Timetables', Text('Lesson Time',"mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy")), 'Lesson Time',Ascending )
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Sort by date and time

Hi @lgillett 

I think you just have to modify the Items property of your Gallery so that it sorts by your 'lesson time' column. The formula would look like this:

 

SortByColumns(Filter('Music Timetables', 
StartsWith('Student Name', TextSearchBox1.Text)),
"Lesson Time",
Descending)
)
lgillett
Level: Powered On

Re: Sort by date and time

Hi @timl ,

 

Thanks for your suggestion. I tried this and my data just disappears and brings up lots of formula errors.

 

The title of the column seems to be: ThisItem.'Lesson Time'. Would this change anything?

 

Is it something to do with TextSearchBox1.Text? I have hidden the text search box and sort up/down functions and refresh etc as these arent required by front end users. They are still there but just hidden.

 

Im really at a loss as to why the colum isnt sorting easily!

 

Thanks

lgillett
Level: Powered On

Re: Sort by date and time

Hi,

 

I am still unable to figure out this issue.

 

Anyone able to shed some more light on something that I music be missing?

 

Thank you!

Dual Super User
Dual Super User

Re: Sort by date and time

Hey @lgillett 

 

Can you try out the below expression on the gallery items:
 
SortByColumns(Filter('Music Timetables', StartsWith('Student Name', TextSearchBox1.Text)), "LessonTime", If(SortDescending1, Descending, Ascending))
 
If this gives an error, please share more details about the type of this column.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
lgillett
Level: Powered On

Re: Sort by date and time

Thank you for your response. I finally managed to sort this by completely changing the formula to:

 

Sort('Music Timetables', 'Lesson Time',Ascending )

 

This seems to have had the desired affect.

 

I do now have another question which is, How would I now sort the same column to show only items for todays date?

 

So for example; On a monday, list entries that apply to Monday would be the only items that show on a Monday.

 

Screenshot 2019-10-04 at 09.54.31.png

 

The column that I want to sort this from is: ThisItem.'Lesson Time'

 

Thank you for your help!

Dual Super User
Dual Super User

Re: Sort by date and time

Hey @lgillett 

 

In that case, you can update the formula as:
 
Sort(Filter('Music Timetables', Text('Lesson Time',"mm/dd/yyyy") = Text(Today(),"mm/dd/yyyy")), 'Lesson Time',Ascending )
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

lgillett
Level: Powered On

Re: Sort by date and time

@yashag2255 Amazing! Thank you very much for your help. I really appreciate it.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,706)