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

Sorting a combo box problem. Please help!!

Hi.

I'm hoping someone cleverer than me can help.

I have a Dropdown and two Combo boxes:

DropdownSoftware_2 

ComboBoxSystem_2 

ComboBoxTask

 

The items in ComboBoxTask are gathered from the selected values of DropDownSoftware_2 and ComboBoxSystem_2

All good so far!

 

The issue is that I can't seem to sort the items in ComboBoxTask. I've used the following code, but the results remain unsorted. Can anyone spot where I've gone wrong?

Sort(Filter('Keystroke Library',Title=DropdownSoftware_2.SelectedText.Result And System=ComboBoxSystem_2.Selected.Result).Task,Ascending)

 

Can anyone spot where I've gone wrong?

 

Many thanks, Stuart.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Sure, I'll flag the spot you need to put a column name or something like that to sort on. I'll put Title for now:

Sort(
    Filter('Keystroke Library',
        Title=DropdownSoftware_2.SelectedText.Result And 
        System=ComboBoxSystem_2.Selected.Result
    ),
    Title, // Switch out Title for another column to do the sorting by
    Ascending
)

You can sort by different columns, so you need to define which one.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

Hi!

I sorted the issue by declaring a collection and referring to that, rather than the data source directly. 

This also fixed my Delegation warning issue! Happy Days.

Thanks everyone for your help. x

View solution in original post

9 REPLIES 9
BCLS776
Super User
Super User

Yes, you need to have a second argument in your Sort() function for the basis of sorting. This can be as simple as the column name in your filtered results on which you want to sort.

 

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi, Bryan.

I'm not sure how that code looks. Any chance you could elaborate? I'm a newbie to Power Apps so would appreciate some help.

 

Thanks, Stuart.

Sure, I'll flag the spot you need to put a column name or something like that to sort on. I'll put Title for now:

Sort(
    Filter('Keystroke Library',
        Title=DropdownSoftware_2.SelectedText.Result And 
        System=ComboBoxSystem_2.Selected.Result
    ),
    Title, // Switch out Title for another column to do the sorting by
    Ascending
)

You can sort by different columns, so you need to define which one.

 

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

Thank you, Bryan. It worked absolutely perfectly. x

I may have closed this too soon!

It seems that if I use Sort on this Combobox, it only works if I have 'Search' disabled on the Combo.

I need the search facility within is item, but if I turn it on then nothing populates the Combobox. If I remove the Sort from the Items and make Search true, then the Combobox gets populated, but isn't in alphabetical order. Any idea why this is behaving in this way?

BCLS776
Super User
Super User

Could you check these settings available in the properties menu that usually appears on the right-hand side of the editor?:

BCLS776_0-1633565844070.png

I wonder if the Primary text and/or SearchField needs to be set correctly on your combobox. I can turn searching on with a Sort() function in the Items and the combobox will both sort correctly and allow searching.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Mrsflea99
Regular Visitor

Hi! This image shows how I've set up the Combo Boxes:

Mrsflea99_0-1633644082697.png

Can you spot anything obviously wrong? Also, when I add the sort code to SearchBox_Task_1, I get the Delegation warning triangle.

 


@Mrsflea99 wrote:

Hi! This image shows how I've set up the Combo Boxes:

Mrsflea99_0-1633644082697.png

Can you spot anything obviously wrong? Also, when I add the sort code to SearchBox_Task_1, I get the Delegation warning triangle.

 


The only thing really jumping out at me is the Sort() is operating on a column called Task and the combobox is displaying/searching on a column called field_Task. Are those two separate columns in your Keystroke Library table, or is one a mistype?

 

The yellow triangle is flagging a potential delegation issue if 'Keystroke Library' contains row more than your delegation row limit (default 500, can be set to 2000). We can make that go away through a small change to the code, but for now let's get your combobox working.

 

Also, try the nearly-identical function SortbyColumns() instead of Sort() -- just remember to put the column name in double quotes for that function. I'm curious if there is any difference.

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi!

I sorted the issue by declaring a collection and referring to that, rather than the data source directly. 

This also fixed my Delegation warning issue! Happy Days.

Thanks everyone for your help. x

View solution in original post

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 (1,794)