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 List and Display ...
Power Apps
Unanswered

Sort List and Display Last Value in Gallery

(0) ShareShare
ReportReport
Posted on by 1,265

I have a SP List of Vehicles where we track mileage.  I want to have a gallery that lists the highest mileage value identified for each vehicle in out fleet.  What would the Filter/Sort syntax be?

 

VehInsp is the SP List

VehNo.Value is the identifies the Vehicle ID

CurrentMileage would hold the value of the highest mileage  

 

Categories:
  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    So do you want to just sort the mileage in the gallery by highest to lowest if so it would be:

     

    Sort(VehInsp,CurrentMileage,Descending)

    the opposite would be:

     

    Sort(VehInsp,CurrentMileage,Ascending)

  • RJF61 Profile Picture
    1,265 on at

    Hello @AJ_Z Thanks for the response.  I want the gallery to display each vehicle with the highest mileage value associated with that Vehicle.

     

    As an example, there are 25 records for Vehicle 1.  I would like to display the record for Vehicle 1 that contains the highest mileage value.  The same would be true for Vehicle 2, 3, 4, etc.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Okay I think I understand now apologies so you want something like this:

     

     

    DropColumns(
     AddColumns(
     GroupBy(
     AddColumns(
     'Power App Test',
     "temp",
     testchoices.Value
     ),
     "temp",
     "grouped"
     ),
     "Mileage",
     Max(
     grouped,
     testnumber
     )
     ),
     "grouped"
    )

     

     

    the above works i have tested it my end

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @RJF61, you could do this by using the code below in you Items property of your gallery.
    The code below will loop through the unique vehNo's of your list and retrieve the record with the highest mileage for each.

     

     

    With(
     {
     VehNoList: Distinct(
     VehInsp,
     VehNo.Value
     )
     },
     ForAll(
     VehNoList As Main,
     First(
     Sort(
     Filter(
     VehInsp,
     Main.Result = VehNo.Value
     ),
     mileage,
     Descending
     )
     )
     )
    )

     

     

     
    If this solves your question, would you be so kind as to accept it as a solution.
    Thanks!

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Hey @RJF61 , Just checking in, did my solution work for you if so please accept it as a solution.

     

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 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard