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 multiple columns ...
Power Apps
Unanswered

Sort multiple columns as per selected selected column

(0) ShareShare
ReportReport
Posted on by 2

Hi,

I have to Sort the data for six columns as below details

I can sorting column 1 , 2 and 5 but 3, 4, and 6 are not working from below function. I was updating context like {sortByColumn: 1, sortOrder: !sortOrder} so on....from Onselection of six different Sort icons for each column

Sayyad_0-1654971472371.png

 

Sort(
 sharepointSitesCollection,
 If(
 sortByColumn = 1,
 Text('Title (SiteTitle)'),
 If(
 sortByColumn = 2,
 Created,
 If(
 sortByColumn = 3,
 'PRIMARY_OWNER'.'DisplayName',
 If(
 sortByColumn = 4,
 'SECONDARY_OWNER'.'DisplayName',
 If(
 sortByColumn = 5,
 Text('Expiration Date'),
 If(
 sortByColumn = 6,
 'External Access'
 )
 )
 )
 )
 )
 ),
 If(
 sortOrder,
 Ascending,
 Descending
 )
 )

 

 Thanks

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

    Hi @Sayyad ,

    Try this - note you will be limited by what you sort with Delegation as you need AddColumns to sort by complex field types and calculations.

    Sort(
     AddColumns(
     sharepointSitesCollection,
     "SecOwner",
     'SECONDARY_OWNER'.DisplayName,
     "PrimOwner",
     'PRIMARY_OWNER'.'DisplayName',
     "Site",
     Text('Title (SiteTitle)'),
     "Expiry",
     Text('Expiration Date')
     ),
     Switch(
     sortByColumn,
     1,
     Site,
     2,
     Created,
     3,
     PrimOwner,
     4,
     SecOwner,
     5,
     Expiry,
     6,
     'External Access'
     ),
     If(
     sortOrder,
     Ascending,
     Descending
     )
    )

     

    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.

    Visit my blog Practical Power Apps

  • Sayyad Profile Picture
    2 on at

    can we use directly Switch instead of AddColumns ??

     

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

    @Sayyad ,

    No - because you cannot sort with complex field types (it is one of the many reasons I use them very rarely)

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