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 / Sort values in Combo box
Power Apps
Answered

Sort values in Combo box

(0) ShareShare
ReportReport
Posted on by 559

Hi All,

I have a Combo box which gets values of a column in SharePoint. I am using a with function to get the values from SharePoint which is getting displayed properly. But the values in the Combo box are not sorted alphabetically.

The code in the item's property is:

With (
{
Items: Ungroup (
For All (
Customer Accounts,
'Account Manager'
),
"Value"
),
Distinct Email: Distinct(
Ungroup (
For All (
Customer Accounts,
'Account Manager'
),
"Value"
),
Email
)
},
Sort(
For All (
Distinct Email,
First (
Filter(
Items,
Email = Result
)
)
),
!IsBlank(DisplayName)
)
)

 

Any help on this would be greatly appreciated.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    Hi @Uthhra ,

    I cannot get the code you posted to validate, however if you are wanting the Distinct values of the (I assume) Person field 'Account Manager' in the List CustomerAccounts, with the two fields of Item and Email, this should do and Sort as well

    Sort(
     AddColumns(
     RenameColumns(
     GroupBy(
     AddColumns(
     CustomerAccounts,
     "EmailAdd",
     'Account Manager'.Email,
     "Staff",
     'Account Manager'.DisplayName
     ),
     "EmailAdd",
     "Data"
     ),
     "EmailAdd",
     "Email"
     ),
     "Item",
     First(Data).Staff
     ),
     Item
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Sri Profile Picture
    559 on at

    Hi @WarrenBelz ,

    I tried applying the above code and got error Sort has invalid arguments. Account Manager is a person or group field in SharePoint which allows multiple selections. I have a shared a screenshot of the error.

  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    Hi @Uthhra ,

    OK - it would have been good to mention that - try this

    With(
     {
     Items: 
     Ungroup (
     ForAll (
     'Customer Accounts',
     'Account Manager'
     ),
     "Value"
     )
     },
     With(
     {
     DistinctEmail: 
     Distinct(
     Items,
     Email
     )
     },
     Sort(
     ForAll(
     DistinctEmail,
     LookUp(
     Items,
     Email = Result
     )
     ),
     DisplayName
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Sri Profile Picture
    559 on at

    Hi @WarrenBelz ,

     Thanks a lot. It worked perfectly. But I am getting a Blank value at the end.

  • Verified answer
    WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    @Uthhra ,

    If that really matters, do this

    With(
     {
     Items: 
     Ungroup (
     ForAll (
     'Customer Accounts',
     'Account Manager'
     ),
     "Value"
     )
     },
     With(
     {
     DistinctEmail: 
     Distinct(
     Items,
     Email
     )
     },
     Sort(
     Filter(
     ForAll(
     DistinctEmail,
     LookUp(
     Items,
     Email = Result
     )
     ),
     !IsBlank(DisplayName)
     ),
     DisplayName
     )
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Sri Profile Picture
    559 on at

    Hi @WarrenBelz,

    It worked perfectly. Thank you so much.

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard