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

BrowseGallery1 not sorted correctly and SortByColumns not working all

I'm making an IT asset list and creating a PowerApp to sort and edit existing list items and add new items to the list.

 

BrowseScreen1 Fields:

  • Body1 = Availability
    • Display value = Value
  • Subtitle1 = User
    • Display value = DisplayName
  • Title1 = ThisItem.'Asset Number'

The Asset Number field in my SharePoint list is Number

 

BrowseGallery1.Items = SortByColumns(Filter([@'Asset List'], StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

The items are showing up in the PowerApp, just not sorted by Asset Number as I was hoping. 

 

I also have a TextSearchBox1.Default = " "

It's format is Text

 

When I enter anything in the Search items field my list goes blank...

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

So your only issue with this formula is that it doesn't sort, correct? 

 

Please try this to sort by Asset Number: 

 

SortByColumns(Filter(AddColumns('Asset List', "AssetNumberText", Text('Asset Number')), StartsWith(Text('Asset Number'), TextSearchBox1.Text)), "AssetNumberText", If(SortDescending1, Descending, Ascending))

 

Let me know if this helps. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

Thanks!
Hardit Bhatia
https://thepoweraddict.com

 

View solution in original post

16 REPLIES 16
Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

Hi,

If you want to sort by asset number and since it is a number field, you can try something like this:

SortByColumns(AddColumns(Filter([@'Asset List'], "AssetNumberText", Text('Asset Number')), StartsWith(Title, TextSearchBox1.Text)), "AssetNumberText", If(SortDescending1, Descending, Ascending))

Regarding your search box issue, what do you exactly want to use that search text for? To search by title, asset number, any other column or combinations of a few columns? Let me know then I can help.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com

Highlighted
Regular Visitor

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

The code you provided is not working either..

 

I attached a screenshot to help explain what it looks like and what I am trying to do.

 

At a minimum I would like to search by asset number but sorting by User would also be nice.

 

Thanks,

Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

I thought you wanted to sort by asset number (from your original post).

So just to be sure that I am working off of the correct requirements:
1. You want to sort by user (username I suppose)?
2. You want to search by asset number

SortByColumns(Filter([@'Asset List'], StartsWith('Asset Number', Value(TextSearchBox1.Text))), "UserName", If(SortDescending1, Descending, Ascending))

I have assumed that your column names are Asset Number and UserName. Please change these with your actual column names and let me know if it works.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com
Highlighted
Regular Visitor

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

My columns are Asset Number and User. I modified and used the code like below and it's still not working...

SortByColumns(Filter([@'Asset List'], StartsWith('Asset Number', Value(TextSearchBox1.Text))), "User", If(SortDescending1, Descending, Ascending))

 

I get 5 errors:

1. Invalid argument type (Number). Expecting a Text value instead.

2. Invalid argument type (Number). Expecting a Text value instead.

3. The function 'Starts With' has some invalid arguments.

4. The function 'SortByColumns' has some invalid arguments.

5. Cannot sort on the expression type.

Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

Try this:

SortByColumns(Filter(AddColumns([@'Asset List'], "UserName", User.'Full Name'), StartsWith(Text('Asset Number'), TextSearchBox1.Text)), "UserName", If(SortDescending1, Descending, Ascending))

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com
Highlighted
Regular Visitor

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

This isn't working either... Hmm

Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

Can you share the errors that you are seeing now?
Highlighted
Super User
Super User

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

Try this as well:

SortByColumns(Filter(AddColumns([@'Asset List'], "UserName", User.'Full Name', "AsserNumberText", Text('Asset Number')), StartsWith(AssetNumberText, TextSearchBox1.Text)), "UserName", If(SortDescending1, Descending, Ascending))

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit Bhatia
https://thepoweraddict.com
Highlighted
Regular Visitor

Re: BrowseGallery1 not sorted correctly and SortByColumns not working all

1. Name isnt valid. This identifier isn't recognized. This error appears most commonly when a formula refers to something that no longer exists (for example, a control that you've deleted).

 

2. The function 'AddColumns' has some invalid arguments.

 

3. The function 'SortByColumns' has some invalid arguments.

 

4. Cannot sort on the expression type.

Helpful resources

Announcements
Check this Out

Announcing

Class of 2020- Season 2

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,086)