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 / Gallery sorting by cal...
Power Apps
Answered

Gallery sorting by calculated fields

(0) ShareShare
ReportReport
Posted on by 23

hi all, 

I am currently working on App to record Employee Absences. 

It is based on SharePoint lists: 

Employees

  • Employee ID (text)
  • First Name (text)
  • Surname (text)
  • Department (text)

Absences

  • Employee ID (text)
  • From (date)
  • To (date)
  • Date of return (date)
  • Days (number)
  • Category (text)

This reports counts occasions and days employees have been sick

IR_06_0-1714726272175.png

Occasions are calculated using below:

IR_06_1-1714726492434.png

Days are calculated using below:

IR_06_2-1714726529945.png

I am looking for a way to sort this gallery by Occasions or Days so it's easier to use. 

 

 

 

Categories:
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @IR_06 - see example below you can apply into the Items property of your Gallery control:

     

    Sort(
     AddColumns(
     Employees As _data,
     DaysAbsent,
     Sum(
     Filter(
     Absences,
     'Employee ID' = _data.'Employee ID'
     ),
     Days
     ),
     Occasions,
     CountRows(
     Filter(
     Absences,
     'EmployeeID' = _data.'EmployeeID'
     )
     )
     ),
     DaysAbsent,
     SortOrder.Descending
    )
  • IR_06 Profile Picture
    23 on at

    @Amik thank you for help

     

    This has worked beautifully for my report. I have been trying to do the same for another report but unsuccessfully. This particular one is looking as absence days in last 3 years.

    Each column under Days is displaying 1 out of 3 years. 

    IR_06_0-1715088932008.png

    I would like sort it by most absences in in total time period of 3 years. 

    I have tried applying same logic as for last one but seems that it's not sorting it. 

    Current code:

    IR_06_1-1715089251199.png

    Could anyone advice what kind of mistake I have made there?

    Thanks😊

     

  • IR_06 Profile Picture
    23 on at

    This has been solved now. Just a silly error in defining collection 😅

  • Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @IR_06 - sorry I did not receive the usual notification that you had responded. Glad you got it sorted.

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