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 get latest reco...
Power Apps
Unanswered

How to get latest records for each group by effective date

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I have a dataset in which I have the data set up in the following way:

 

bdsouza9_0-1675430663914.png

 

This data is currently residing within the Dataverse and I would like to set up either a Data table or Gallery to pull from here and show the latest records for each eventID, along with all the attributes listed. So rather than just the eventID and the max eventCreatedTime for the eventID, I also want to know the additional attributes (eventMetric, eventAdjustedAmount) for those records, which in the example above is not limited to one row, but can be multiple rows (2,3,4,etc).

 

I have found some solutions online through this forum but most seem to only produce one row per group, whereas I would like to grab multiple by group (if multiple records exist for that group and that max eventCreatedTime). Please let me know if you have any thoughts. I appreciate your help.

 

I tried the following code which resulted it one row per eventID

 

ForAll(
GroupBy(eventDetails,
"cr2cc_eventID, "_records"
),
With({_top: First(Sort(_records, eventCreatedTime, Descending))},
{eventID: cr2cc_eventID,
dateCreated: _top.eventCreatedTime,
eventAdjustedAmount: _top.eventAdjustedAmount,
eventMetric: _top.eventMetricOrValue
}
)
)

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

    @bdsouza9 

    Use a gallery and subgallery to display your results.  For the Items property of the main gallery : GroupBy(eventDetails,"cr2cc_eventID, "_records")

    In the Item property of the SubGallery:  Sort(ThisItem._records, eventCreatedTime, Descending)

    Place labels inside the subgallery for ThisItem.eventCreatedTime, ThisItem.eventMetric, ThisItem.eventAdjustedAmount.

    You could even put a label in the main gallery and use Sum(ThisItem.DATA,ThisItem.eventAdjustedAmount) to get aggregate functions on the data in the subgallery or obtain the latest information by placing a label in the main gallery: First(Sort(ThisItem.eventCreatedTime,Descending)).eventMetric

     

     

     

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 414

#2
WarrenBelz Profile Picture

WarrenBelz 377 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 315 Super User 2026 Season 1

Last 30 days Overall leaderboard