web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to Append the Late...
Power Apps
Unanswered

How to Append the Latest Creation Date From a SharePoint List to an Existing Collection

(0) ShareShare
ReportReport
Posted on by 38

I have a collection of data 'FacilityCollection' that contains a list of unique facilities (unique identifier is 'facility_id'). I would like to show the entire 'FacilityCollection', but add a column that shows the most recent/max 'last_updated' date from the SharePoint list 'sp_form_facility' (matching 'facility_id' from 'FacilityCollection' to 'current_fac_id' from 'sp_form_facility'.

 

Basically, I am trying to provide a list of all facilities and see when is the last time they sent us an update or show a blank in the 'last_updated' field if no update has ever been sent.  See the 'Desired Output' table below for an example of what I am looking for. 

 

Any help would be greatly appreciated! Thank you!!

 

 

FacilityCollection

facility_idlocation
1Chicago
2New York
3Memphis
4Tampa
5Miami
6Tempe
7Billings
8Atlanta
9Dallas

 

 

sp_form_facility

current_fac_idcreated_dateupdate_notes
11/1/2024Testing
11/2/2024Hello
41/3/2024Hi
21/4/2024Test
41/5/2024Bye

 

Desired Output 

facility_idlocationlast_updated
1Chicago1/2/2024
2New York1/4/2024
3Memphis 
4Tampa1/5/2024
5Miami 
6Tempe 
7Billings 
8Atlanta 
9Dallas 

 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @nicktalsma,

     

    The following code should do the trick:

    AddColumns(
     //Add column called last_updated
     FacilityCollection,
     "last_updated",
     //Fetch the last created record's date for this facility id
     First(Sort(Filter(sp_form_facility, facility_id = current_fac_id), 'created_date', SortOrder.Descending)).'created_date'
    )

     

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

  • nicktalsma Profile Picture
    38 on at

    @LaurensM that worked perfect!  A little slow, but I figure I can solve for that by filtering 'FacilityCollection', as there are about 1,000 records in that collection. 

     

    One more question, which I assume is probably simple... How do I also add the 'update_notes' from the most recent record from sp_form_facility? Should like like below output. 

     

    Thank you so much!!!

     

    Desired Output 

    facility_idlocationlast_updatednotes
    1Chicago1/2/2024Hello
    2New York1/4/2024Test
    3Memphis  
    4Tampa1/5/2024Bye
    5Miami  
    6Tempe  
    7Billings  
    8Atlanta  
    9Dallas  
  • LaurensM Profile Picture
    12,516 Moderator on at

    @nicktalsma,

     

    To avoid multiple API calls within the same record I will swap the AddColumns to ForAll, allowing us to use the With function:

    ForAll(
     FacilityCollection,
     With(
     {
     wFacilityForms: Sort(Filter(sp_form_facility, facility_id = current_fac_id), created_date, SortOrder.Descending)
     },
     {
     facility_id: facility_id,
     location: location,
     //Fetch both the notes & date of the most recent record
     'last_updated': First(wFacilityForms).'created_date',
     notes: First(wFacilityForms).notes
     }
     )
    )

     

    Should you have a lot of facilities (even after filtering), it may be beneficial to store the most recent note & update date within your Master Data list (each loop is an API call to your sp_form_facility list).

     

    In other words, when a new sp_form_facility is added, it updates the master data facility list for those 2 fields. This allows you to simply display the Master Data list instead of merging this with the most recent data.

     

    I hope this helps!

  • nicktalsma Profile Picture
    38 on at

    Hmm, isn't ForAll non-delegable? 

     

    If using your original solution, would this be the correct syntax for adding the most recent notes column? Thank you!

    AddColumns(
     //Add column called last_updated
     FacilityCollection,
     "last_updated",
     //Fetch the last created record's date for this facility id
     First(Sort(Filter(sp_form_facility, facility_id = current_fac_id), 'created_date', SortOrder.Descending)).'created_date',
     "notes",
     First(Sort(Filter(sp_form_facility, facility_id = current_fac_id), 'created_date', SortOrder.Descending)).'update_notes'
    )

     

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @nicktalsma,

     

    Delegation-wise there is no difference between AddColumns & ForAll. Both will return a table of records with the size dependent on your Data Row Limit. The Filter within the ForAll is delegable.

     

    Your code indeed is correct. 😊 Keep in mind that AddColumns requires 2 seperate Filter functions whereas the ForAll would only fetch the data once.

     

    I hope this helps!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard