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 / Sorting not working wi...
Power Apps
Answered

Sorting not working with collection

(0) ShareShare
ReportReport
Posted on by 172

i am creating a collection with 4 column names and wanted to sort it

 

   

Sort(
    ForAll(
        empid,
        Collect(
            empwithsal,
            {
                empid: ThisRecord.ID,
                empnumber: ThisRecord.'empnumbers',
                emprole: ThisRecord.role,
                joindate: ThisRecord.joindate
            }
        )
    ),
    SortOrder.Descending
);
 
 
i want to sort it with empid the higher staring with higher at the top. 
 
if i add a column name then it gives me error, and currently it is not working. 
Categories:
  • Verified answer
    Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @KDAI 

     

    To create a sorted collection based on empid, you should first use Collect to create the collection and then use Sort to sort that collection. Here's how you can do it:

     

    Create the collection with Collect:

     

    Clear(empwithsal); // Clear the collection if it already exists
    ForAll(
    empid,
    Collect(
    empwithsal,
    {
    empid: ID,
    empnumber: 'empnumbers',
    emprole: role,
    joindate: joindate
    }
    )
    );

     

    Sort the collection and store it in a new collection or variable:

     

    ClearCollect(
    SortedEmpWithSal,
    Sort(
    empwithsal,
    empid,
    SortOrder.Descending
    )
    );

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard