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 / Search a gallery for t...
Power Apps
Answered

Search a gallery for the earliest record, retrieve that date to be displayed on a text label

(0) ShareShare
ReportReport
Posted on by 24

I have a parent table (Milestones) with a child table (Activities). For the Milestone's Start date I want to write a function that finds the start date for the first activity of the Milestone. 

 

Here is my logic: 

 
  Lookup(Actvities, MilestoneID = selected_record.MilestoneID),
      SortByColumns(Activities, "DateStarted", Descending))

Kinda stuck. Thanks!



Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,926 Most Valuable Professional on at

    Hi @dataguy33 ,

    I am assuming here that selectedRecord.MilestoneID is a Variable matching the field MilestoneID in Activity. If so, try this

    With(
     {
     wActive:
     Sort(
     Activities,
     DateStarted,
     Descending
     )
     },
     Lookup(
     wActive, 
     MilestoneID = selected_record.MilestoneID
     )
    )

     

    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.

  • dataguy33 Profile Picture
    24 on at

    The only thing you missed was, the field that needed to be displayed in the lookup function. So:

     

    With(
    {
    wActive:
    Sort(
    Activities,
    DateStarted,
    Descending
    )
    },
    Lookup(
    wActive,
    MilestoneID = selected_record.MilestoneID, DateStarted
    )
    )

     

    Really useful though, thank you @WarrenBelz !

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

    Thanks,

    Dangers of free-typing code - I see that now.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard