cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
schandra1
Frequent Visitor

Unable to sort by date

Hi

 

I'm trying to use the sort icon to sort by start date for an Onboarding form but not getting anywhere. 

 

Capture99.JPG

Currently the Items property of gallery looks like this: SortByColumns(Filter([@'New User Process'], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

The OnSelect looks like this: UpdateContext({SortDescending1: !SortDescending1})

 

I'm new to Powerapps so any help would be greatly appreciated.

 

Cheers

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @schandra1 ,

You just need the below - put your actual date field name where shown below.

SortByColumns(
   Filter(
      [@'New User Process'], 
      StartsWith(
         Title, 
          TextSearchBox1.Text
      )
   ), 
   "YourDateFieldName",   //put actual date field name in here
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @schandra1 ,

You just need the below - put your actual date field name where shown below.

SortByColumns(
   Filter(
      [@'New User Process'], 
      StartsWith(
         Title, 
          TextSearchBox1.Text
      )
   ), 
   "YourDateFieldName",   //put actual date field name in here
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

v-yutliu-msft
Community Support
Community Support

Hi @schandra1 ,

I agree with @WarrenBelz 's formula.

Just to supplement his reply.

Please notice the syntax of SortByColumns function:

SortByColumnsTableColumnName1 [, SortOrder1ColumnName2SortOrder2, ... ] )

The columnname decides sort by which column and the order of column name decides the sort order.

However, in your formula, the column name is Title, not StartDate.

SortByColumns(Filter([@'New User Process'], StartsWith(Title, TextSearchBox1.Text)),

                          "Title",

                         If(SortDescending1, Descending, Ascending))

So the sort icon will not work for start date.

 

If you only want to sort based on startdate, you just need to replace Title with startdate field.

Try this:

SortByColumns(Filter([@'New User Process'], StartsWith(Title, TextSearchBox1.Text)), "StartDate", If(SortDescending1, Descending, Ascending))

If you not only want to sort based on title but also want to sort based on startdate, you just need to add startdate field.

Try this:

SortByColumns(Filter([@'New User Process'], StartsWith(Title, TextSearchBox1.Text)), 
              "Title",Ascending,
              "StartDate", If(SortDescending1, Descending, Ascending)
               )

 

 

Here's a doc about this function for your reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-sort

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 Hi Guys

 

Changing the start date field worked like a charm.

 

Thank you both for your help.

 

Cheers

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,484)