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 / Distinct Last Filter f...
Power Apps
Unanswered

Distinct Last Filter for Gallery

(0) ShareShare
ReportReport
Posted on by

Good morning! I have a SP list that tracks the status of vehicles and if they are checked in or checked out. I'm trying to build a gallery that filters the last status of each of the vehicles and only displays vehicles that are checked in. My distinct filter works, but since each of the vehicles have been checked in at one point, it returns all of the vehicles as checked in. I assume last() is the function I need to find the most recent status of the vehicle, but I cant get a working formula for it:

 

Distinct(Filter('Vehicle Tracker', EquipmentStatus.Value = "Checked In"),IdentificationNumber)

 

Can anyone help with how to get the most recent vehicle status and filter for those only checked in? 

 

Thank you! 

Categories:
I have the same question (0)
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @Applications ,
    You can use something like below - 

    Distinct(Filter('Vehicle Tracker', EquipmentStatus.Value = "Checked In" && Status.Value = Last('Vehicle Status').Status.Value),IdentificationNumber)

     

  • Applications Profile Picture
    on at

    Using the formula here:

    Distinct(Filter('Vehicle Tracker', EquipmentStatus.Value = "Checked In" && 'Vehicle Status'.Value = Last('Vehicle Tracker').EquipmentStatus.Value),IdentificationNumber)

    It does provide a distinct list of the vehicles, but I cannot change any of the ThisItem.X properties in the gallery itself. It only limits it to "ThisItem.Value.Value". I also believe the distinct list is not filtering for vehicles only "checked in", but rather shows all of the vehicles. Thoughts?

     

  • Applications Profile Picture
    on at

    Can anyone support the issue above? Trying to get this to a place that is a workable gallery. Thank you!

  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @Applications ,
    Try using below formula - 

    ForAll(GroupBy(Filter('Vehicle Tracker', EquipmentStatus.Value = "Checked In" && 'Vehicle Status'.Value = Last('Vehicle Tracker').EquipmentStatus.Value), "IdentificationNumber", "_records"),
     With({_record: First(Sort(_records, Created, Descending))},
     Patch(_record, {IdentificationNumber: IdentificationNumber})
     )
    )
    
  • Applications Profile Picture
    on at

    This doesn't work either for some reason. I should mention the "IdentificationNumber" or 'Vehicle ID Number' column is a choice column. I'm not sure if that affects the formula above, but the error I got was that it was looking for literal text in the GroupBy segment.

  • Applications Profile Picture
    on at

    Any ideas on how to get the gallery to display correctly? Still trying to figure out how to see the latest record for each vehicle and then filter it to only checked in vehicles.

  • WarrenBelz Profile Picture
    156,454 Most Valuable Professional on at

    Hi @Applications ,

    Try this and note at the bottom you need to add any other columns you need to see in the relevant record back in with the structure shown

    Filter(
     AddColumns(
     GroupBy(
     AddColumns(
     Sort(
     'Vehicle Tracker',
     ID,
     SortOrder.Descending
     ),
     "IDNumber",
     IdentificationNumber.Value
     ),
     "IDNumber",
     "Data"
     ),
     "Status",
     First(Data).EquipmentStatus.Value,
     "OtherColumn1",
     First(Data).OtherColumn1
     ),
     Status = "Checked In"
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

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
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard