cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JTischler
Helper II
Helper II

Sort title Alphabetically

This seems so simple, but I cant get it to work.  I want to sort my gallery alphabetically by title.  I have a text input with a search feature currently.  My current code is:

 

Search([@BOP],txtBOPSearch.Text,"Title","CourseID_x0028_CO_x0029_")

 

I have tried to merge the following code:

 

SortByColumns(Filter([DataSource], [Formula]), "Title1", If(SortDescending1, Descending, Ascending))

 

My end result was:

 

SortByColumns(Search([@BOP],txtBOPSearch.Text,"Title","CourseID_x0028_CO_x0029_"), "Title", If(SortDescending1, Descending, Ascending))

 

but I get an error about an invalid IF argument.  How should this code appear?

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@JTischler 

If you only want A-Z, then just set the formula to:

SortByColumns(
    Search([@BOP],
       txtBOPSearch.Text, "Title", "CourseID_x0028_CO_x0029_"
    ), 
    "Title"
)
_____________________________________________________________________________________
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

9 REPLIES 9
RandyHayes
Super User
Super User

@JTischler 

What kind of column is CourseID_x0028_CO_x0029_?

Your Formula is correct, but if the above column is not a text column, then the error is really on your Search function as it can only operate on text columns.

 

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!
WarrenBelz
Super User
Super User

Hi @JTischler ,

There is nothing wrong with the last piece of code provided, but the error may suggest you do not have a control somewhere setting SortDescending

You could also try this

Search(
   Sort(
      [@BOP],
      Title,
      If(
         SortDescending1, 
         Descending, 
         Ascending
      ),
      txtBOPSearch.Text,
      "Title",
      "CourseID_x0028_CO_x0029_"
   )
)

 

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.

cwebb365
Super User
Super User

"Nevermind" read it wrong in e-mail. 

RandyHayes
Super User
Super User

@JTischler 

Yes...I was also assuming that you have an actual variable- SortDescending1 being defined somewhere in your app.

_____________________________________________________________________________________
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!
JTischler
Helper II
Helper II

@RandyHayes @WarrenBelz 

I do not have the SortDescending1 defined anywhere.  I have seen it in a few code snippets, and assumed it was a syntax vs a variable.

 

Yes the CourseID_x0028_CO_x0029_ is a text field and the search is functioning fine.  I just want it to sort the gallery alphabetical by title.

RandyHayes
Super User
Super User

@JTischler 

Ah, there ya go.  You need that variable set to either true or false based on your formula.

Do you want the ability to sort A-Z as well as Z-A?

_____________________________________________________________________________________
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!

@RandyHayes where would I set that variable at?

 

Syntax: Set(SortDescending1,True)??

 

I just want to sort A-Z

RandyHayes
Super User
Super User

@JTischler 

If you only want A-Z, then just set the formula to:

SortByColumns(
    Search([@BOP],
       txtBOPSearch.Text, "Title", "CourseID_x0028_CO_x0029_"
    ), 
    "Title"
)
_____________________________________________________________________________________
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!
JTischler
Helper II
Helper II

Lol I knew it was something simple!!!!  Thanks so much 🙂

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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