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 / 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:
  • WarrenBelz Profile Picture
    156,921 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
    156,921 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
timl Profile Picture

timl 122 Super User 2026 Season 2

Last 30 days Overall leaderboard