Skip to main content

Notifications

Community site session details

Community site session details

Session Id : Nc2jTsAqmXsVSFPksvpMjR
Power Apps - Building Power Apps
Answered

Sort a distincted column based on another column values

Like (0) ShareShare
ReportReport
Posted on 13 Jun 2023 13:16:10 by 67

Dear Power apps experts,

 

I have created an App using a gallary which is connected to SP list as "data source".

I am trying to create a combobox and combaine two functions (Distinct and sort) but not successed yet.

 

The combobox supposes to show a list of values from a column in the data source (table from SP). The values must be sorted based on another column. For instance, If we suppose that we have two columns on SP list, column A and B. I what is want to do is, to connect the comobobox to column A as dropdown list and to be sorted (Descending) based on column B. 

A (Serie nr)B (ID)
105
74
53
112
31

With other word, I want to create the combobox to have the dropdown list A (Serie nr) and sorted on B (ID), however; the dropdown list should show the results as folowing:

A (Serie nr)
3
11
5
7
10

 

I would appreciate your help.

 

BR

  • Appsforourlife Profile Picture
    67 on 13 Jun 2023 at 13:55:28
    Re: Sort a distincted column based on another column values

    It worked very well!

    Thank you a lot, very apprecieted đź™Ź

  • BCBuizer Profile Picture
    22,048 Super User 2025 Season 1 on 13 Jun 2023 at 13:34:40
    Re: Sort a distincted column based on another column values

    Hi @Appsforourlife ,

     

    My first try would be to use GroupBy instead of Distinct so the rest of the data is preserved and can be used for sorting:

     

    Sort(
    	AddColumns(
    		GroupBy(
    			DataSourceName,
    			"ColumnA",
    			"GroupedByA"
    		),
    		"SortOrder",
    		First(GroupedByA).ColumnB
    	),
    	SortOrder
    )

     

  • Verified answer
    developerAJ Profile Picture
    2,855 on 13 Jun 2023 at 13:29:01
    Re: Sort a distincted column based on another column values
    Distinct(SortByColumns(DataSource,"ColumnB",SortOrder.Descending),ColumnA)

     

    Try this Out

     

    Please click Accept as solution and Thumbs Up. 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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

Overall leaderboard
Loading started