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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Unwanted Sorting of Li...
Power Apps
Unanswered

Unwanted Sorting of Listbox Options from Items in SharePoint Column

(0) ShareShare
ReportReport
Posted on by 54

I am creating a Listbox in the canvas app linked to a SharePoint list column, and the items (rows) seem to be sorted, and I don't want that. I see nothing in edit mode in Properties or Advanced or other parts of the interface indicating why it is being sorted. I want the Listbox select options to read from top to bottom just as it displays in the SP list.

 

Background: I'm just getting started using Power Apps, having heavily made forms/pages using JavaScript/HTML/CSS inside & outside of SharePoint chrome for SP2010/2013/2016 on-premises using REST requests. I see there is no room for client-side scripting (JavaScript) in Power Apps so this will be entirely new for me. Becoming proficient in Power Apps is a required duty for me. If you know of one or more learning resources, I would appreciate link(s) to those resources.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @StevePenner 

    Welcome to PowerApps!!  Leave your developer mind at the door...😂

     

    Can you explain what you mean by a "SharePoint List Column" ?

     

    In general, there is no sorting on items unless you specify it.  It will get and display items in the order received from the datasource.

     

     

  • StevePenner Profile Picture
    54 on at

    @RandyHayes 
    I captured two images below. One is a SharePoint list (named "Configuration -- CAB Agenda") with only one column (named "Level 1 Header"). There are 9 items in the list, and effectively only 9 values in the column.

     

    When the Listbox is created in the app (and I increased its size vertically), the 9 items appear, but now sorted in ascending fashion. You can see the settings of properties.

     

    I have noted that one of the app's automatically created controls is a sort control at the top to toggle between ascending and descending sort, and so a Listbox object (are controls called "objects"?) likely has a property to indicate a sort, which is probably something I want disabled. I am not sure how to go about that.

     

    And once I solve that simple problem, my next thing to figure out is how to add to the Listbox text for each option (item?) a preceding Arabic numerals as follows: "1. " & SP item string1, "2. " & SP item string2, etc.

     

    I am guessing that is done by creating a collection or table (?) and then modifying each string in the collection or table and then using the modified strings in the collection in the Listbox. This is likely all basic beginner stuff to experienced power users.

     

     

    SharePoint List with One ColumnSharePoint List with One ColumnApp Showing Listbox connected to SP List ColumnApp Showing Listbox connected to SP List Column

  • StevePenner Profile Picture
    54 on at

    I have attached two images. One of the SharePoint List named "Configuration -- CAB Agenda" with one column named "Level 1 Header" and having 9 items of data type 'single line of text'. The other is of the app showing the ListBox connected to the column of items. The items in the ListBox are sorted in ascending order at time of connecting the control to the data.

     

    This is not wanted. There is a Sort control made part of the app and so I am guessing that sorting of some control types (like text-style input controls) is automatic. I probably want to disable sorting for these control types and need to figure out how.

     

    After solving the sort problem, I will then want to figure out how to precede an Arabic numeral before each text item in the ListBox, looping in a way that item 1 is "1. " & textItem1, "2. " & textItem2, etc. I am guessing that is done by creating a table or collection of the strings from the data source, when applying a function to prepend the text while running a loop, then connecting the modified collection or table to the ListBox. Or something like that.

     

    SharePoint List With One Column of 9 ItemsSharePoint List With One Column of 9 ItemsListBox Control Connected to SharePoint List ColumnListBox Control Connected to SharePoint List Column

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @StevePenner 

    So, in this case, I would have a look at the View in SharePoint.  How is it sorting?  Because the default sort would be by ID in PowerApps.  If they don't match, then I am speculating that you have a Sort order set on the SharePoint list view.

    Check that out first.

  • StevePenner Profile Picture
    54 on at

    @RandyHayes 
    My SP list had been created new and each item created in that order. I added the SharePoint system-generated item ID to the view so it is clear that the SP sort is by ID value (image below)

     

    I noticed in the Power Apps browser editor as well that when I put a cursor in the table created by the ListBox, the values of the fields in the table appear in a dropdown from the formula input control. In that dropdown of the table and its records and field, there was a column "ID" and its value exactly corresponded to the SP-generated ID values (also imaged below).

     

    After some searching to understand sorting, the function SortByColumn() applied a sort to the ListBox items using the ID column and it worked (image below).

     

    Now on to the next hurdle.

    SP List adding system-generated ID to viewSP List adding system-generated ID to viewDisplay of table records and fields from formula barDisplay of table records and fields from formula barApplying SortByColumn() function to achieve wanted resultApplying SortByColumn() function to achieve wanted result

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @StevePenner 

    Odd...I've never seen PowerApps do anything by record by record sort (i.e. the order in which it was entered...usually the ID).

    Glad you got things going now though.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 793 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 333 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard