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 / Getting records with h...
Power Apps
Answered

Getting records with highest value in identifier, based on part of the identifier

(0) ShareShare
ReportReport
Posted on by 20

I have a Sharepoint list Test and I want to put only the most recent records of each project in a gallery.

The list looks like this, the first 4 characters of the identifier is the project code:

SP_Ontwikkelaar_0-1641462156339.png 

and wanted result is 

SP_Ontwikkelaar_1-1641462285689.png

 

I made a collection col2 by 

ClearCollect(col1,SortByColumns(Test,"Identifier",Descending));
ClearCollect(col2,AddColumns(col1,"Project",Left(Identifier,4)));
ClearCollect(colLatest,GroupBy(col2,"Project","Rest"));
Set(NumberOfProjects,CountRows(colLatest));

 

but then I have to use following instruction to display the values in the gallery [Items:SortByColumns(FirstN(colLatest,NumberOfProjects), "Project")]:

 

First(ThisItem.Rest).Identifier&"-"&First(ThisItem.Rest).Field1

 

Can I put the first record of the embedded table of each record directly in the gallery (or a collection)?

 

 

Categories:
I have the same question (0)
  • SP_Ontwikkelaar Profile Picture
    20 on at

    The result collection is colLatest not col2

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

    Hi @SP_Ontwikkelaar ,

    Try the below

    With(
     {
     wList:
     AddColumns(
     Test,
     "Code",
     Left(Identifier,4),
     "Project",
     Value(Right(Identifier,8)),
     "FullCode",
     Identifier & "-" & Field1
     )
     },
     ClearCollect(
     colLatest,
     DropColumns(
     AddColumns(
     GroupBy(
     wList,
     "Code",
     "Data"
     ),
     "Latest",
     First(
     Sort(
     Data,
     Project,
     Descending
     )
     ).FullCode
     ),
     "Code",
     "Data"
     )
     )
    )

     

    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.

    Visit my blog Practical Power Apps

  • Verified answer
    WarrenBelz Profile Picture
    156,415 Most Valuable Professional on at

    Hi @SP_Ontwikkelaar ,

    Just checking if you got the result you were looking for on this thread. Happy to help further if not.

    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.

    Visit my blog Practical Power Apps

  • SP_Ontwikkelaar Profile Picture
    20 on at

    The solution you gave is GREAT, thanks a lot!

    I've changed a bit so the result is a record subset of the whole list (= containing several fields) with only the highest values and but with the same definition of fields, so both the list and the collection can be used in _one_ gallery, depending on the whishes of the user.

     

    ClearCollect(col1,SortByColumns(Test,"Identifier",Descending));
    With(
     {
     wList:
     AddColumns(
     Test,
     "Code",
     Left(Identifier,4),
     "Project",
     Value(Right(Identifier,8)),
     "Identifier_",
     Identifier,
     "Field1_",
     Field1,
     "Field2_",
     Field2
     )
     },
     ClearCollect(
     colLatest,
     DropColumns(
     AddColumns(
     GroupBy(
     wList,
     "Code",
     "Data"
     ),
    
     "Identifier",
     First(
     Sort(
     Data,
     Project,
     Descending
     )
     ).Identifier_,
     "Field1",
     First(
     Sort(
     Data,
     Project,
     Descending
     )
     ).Field1_,
     "Field2",
     First(
     Sort(
     Data,
     Project,
     Descending
     )
     ).Field2_
    
     ),
     "Code",
     "Data"
     )
     )
    )

     

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

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard