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 / How to sort Main Galle...
Power Apps
Answered

How to sort Main Gallery with GroupBy Items with a sub-Gallery's "worst" Severity Column value?

(0) ShareShare
ReportReport
Posted on by 255

I have an Incidents SharePoint list where I have Program as a Lookup Field (points to Programs SharePoint List). In Incident list I have Severity as a choice column with: Red, Yellow.

 

In PowerApps I have A Gallery A which Groups the Incident list items by Program. So, Gallery A is a List of Programs that have active incidents. I have a nested sub-Gallery B inside Gallery A. Sub-Gallery B lists incidents in the particular Program. In sub-Gallery B items I have color circles indicating the incident severity.

 

My problem is: I would like to have a color square for Gallery A items (Programs) so that it's defined by the worst severity in the sub-Gallery B items: If there are any red ones, the whole Program is red, otherwise yellow. And I want also to sort the Gallery A by Programs' severity.

 

I have tried to set a variable for that but with no success. It's difficult to know, where i should define the variable, and would it be with an if condition.

 

Any ideas?

 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Finnair 

    A variable is not going to be any help, you need to account for this in your Items property of the main gallery.

     

    So, assuming your Formula for the Items property of GalleryA is similar this this:

    GroupBy(
     AddColumns(Incidents,
     "_program", Program.Value
     ),
     "_program",
     "_programRecords"
    )

    And your Items property for GalleryB (nested) is:

    ThisItem._programRecords

     

    Then you would modify the above to the following to get what you want:

    NOTE: I am assuming you have a Severity column that is numeric.

    Sort(
     AddColumns(
     GroupBy(
     AddColumns(Incidents,
     "_program", Program.Value
     ),
     "_program",
     "_programRecords"
     ),
     "_totalSeverity", Max(_programRecords, Severity)
     ),
     _totalSeverity
    )

     

    Your Sub Gallery Items would remain the same.

    Now you will have a _totalSeverity column in your main gallery that you can use to display the colors you want and the list will be sorted by the maximum severity of all the records of that Program.

     

    I hope this is helpful for you.

  • Finnair Profile Picture
    255 on at

    Thank you @RandyHayes 

     

    This really works... after I managed to solve little obstacles.

     

    My Severity column in Sharepoint is a calculated field and it renders in Powerapps as Text and with 13 decimals like 2.0000000000000 although it's a number with 0 decimals in SharePoint. I set Severity DataCard's Default: Left(ThisItem. Severity;1).

     

    Finally, inside Min() function Value(Severity; 'en-GB') was successful (btw my severity values go backwards, and I use semicolons).  

     

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard