web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery not Sorting Co...
Power Apps
Unanswered

Gallery not Sorting Correctly

(0) ShareShare
ReportReport
Posted on by 14

The following code is filtering and sorting my gallery:

 

Sort(
Filter(ProjCollect,
'Doc Selection'.Value = "Drawing",
If(IsBlank(Dropdown_MDLRev.SelectedText.Value),true,Dropdown_MDLRev.SelectedText.Value = 'MDL Revision'),
If(IsBlank(TextInput_DWG.Text),true,TextInput_DWG.Text in 'Drawing Code'),
If(IsBlank(TextInput_Rev.Text),true,TextInput_Rev.Text in 'Drawing Revision'.Value),
If(IsBlank(TextInput_Title.Text),true,TextInput_Title.Text in 'Drawing Title')
),
'Drawing Code')

 

As you can see, the filter simply takes the entire list, extracts items labeled as "Drawing" and then filters it by some dropdowns and text input boxes so users can filter a growing list. The sort should then sort the list in ascending order for people scrolling to find something.

 

I've used the same type of data and the same sort methodology on another PowerApp which works fine. The data comes from a sharepoint list. The field in question is a concatenate of two other fields (e.g. 002-1804000 and C to produce 002-804000-C). The two fields being combined are a text field and choice field. The data being displayed in the Gallery looks like this:

 

002-1804000-C

002-1804136-A

002-1804139-A

002-1603353-A

002-1804010-C

002-1804144-B

..... and so on

 

If I switch the order from default (ascending) to descending it flips the list correctly but that one line item (002-1603353-A) sits there seemingly out of order. If I go into the sharepoint list and use the Sharepoint sorting feature on that column it all sorts fine without an issue. The 002-1603353-A goes right to the top. It's only within the Gallery that it refuses to sort correctly. I have two other galleries on the same page, pulling from the same list, that both sort their items correctly using the same filters and same code.

 

Things I've tried:

- I wondered if that column had become corrupted somehow so I created a new column with the same concatenate code and tried to use that to filter. Same problem.

- I tried switching to sorting with the 'Drawing Number' column which is the first part of the concatenate with the same result of that 002-1603353 item sitting there out of order.

- I deleted the text in the 'Drawing Number' column for the few items surrounding the oddball one, including that one, and re-entered the data to no effect.

- I created a second gallery using the same code thinking something had become corrupted in the gallery but no change in the sorting behaviour.

- I tried switching to SortbyColumns with the same results as the normal Sort function.

 

Thoughts?

Categories:
I have the same question (0)
  • JayMagness Profile Picture
    1,663 on at

    HI,

     

    From what I can see youa re not giving the final part of the sort function. 

     

    Sort(PowerappsCommunityLog1,Created,SortOrder.Descending)

     

    Sort(PowerappsCommunityLog1,Created,SortOrder.Ascending)

     

     

  • Ididar Profile Picture
    14 on at

    The default for the Sort function is SortOrder.Ascending whether you include it specifically or not. In my testing at times I included it, at times left it out. It makes no difference to the function of the Sort. when I put SortOrder.Descending at the end it flips the list around but, as originally noted, it still has that one item out of order, just the list in reverse order.

  • Ididar Profile Picture
    14 on at

    I've had another baffling development.

     

    We've been adding data to the list and another item has popped up out of order as well. The list now reads as ....

     

    002-1804000-C

    002-1804136-A

    002-1804139-A

    002-1804222-A

    002-1603353-A

    002-1804002-C

    002-1804004-C

    002-1804010-C

    ... and so on

     

    So another item that was recently added to the list has popped up out of order. I thought initially that it was sorting them in order of their data entry but that's obviously not the case. I think everything below that 002-1603353 entry is sorted correctly and the items above it are just defying the sort order. I just can't figure out why that's the case.

     

    I've also since tried sorting the list before filtering but that didn't do anything either. Same results. I did two sorts in the same formula as well. I put a sort around ProjCollect and a sort around the filter. Both at the same time had the same results. I had the first one sorting in Descending order and the second one in Ascending order and the same results. I honestly did that on a whim just trying anything no matter how ludicrous.

     

    Since the results flip their order when I switch from Ascending to Descending I know the sort is doing something I just can't figure out why certain data is appearing out of order.

  • Ididar Profile Picture
    14 on at

    Another update. I started re-entering the data for the "Drawing Number" column noted above and the items started shifting in order again on the list. Right now they appear to be sorted correctly. I re-entered the exact same information that was already in the list. I'm just baffled as to why it is suddenly sorting fine now and wasn't before.

     

    Has anyone else noticed data getting corrupted in this manner where putting the same data back in fixes an issue? I don't want to have to constantly be re-entering dozens of entries just to get the sorting to work correctly. This list and Powerapp is supposed to be a long term list with thousands of entries eventually. If there's a way to avoid this happening I want to fix it now.

  • JayMagness Profile Picture
    1,663 on at

    Ok several things to think about...

     

    the greatest number of items you can sort, and search are 2,000 in PowerApps.

     

    This said there are several ways around this I have applications running that search and retrieve over 400,000 records in SharePoint in less than a second so there are ways to tune things. just need to make sure you design things early on well.

     

  • Ididar Profile Picture
    14 on at

    And more data entered and more data out of order. The Sharepoint list sorts fine with the data but you drag it into a PowerApp and it refuses to sort correctly. The powerapp seems to be grabbing chunks of data that were all entered around the same date and sorting that correctly within that "chunk". Previous data entered on a given date is all sorted correctly for that day. But, it won't take all the data and sort it all in Ascending order. It just sorts it within those arbitrary blocks of data.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 600

#2
WarrenBelz Profile Picture

WarrenBelz 478 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard