cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
John_Sieber
New Member

Chart data - Group Sharepoint list and return lastest result from each group

I have a SharePoint list that has multiple records for each user with a column containing a percentage. I would like to use the line chart to show the latest percentage for each distinct user. I'm unsure how to only return the latest record for each distinct user. I think I need to use GroupBy and AddColumns but I'm unsure how to access the most recent record in the Group by results. Example data structure:

 

Name     Result Result Date

Joe          .85      2022-06-20

Randy     .87      2022-06-20

Joe          .81      2022-05-15

Randy     .65      2022-05-14

Barb        .97      2022-05-14

Barb        .88      2022-02-10

 

The data output I want to supply to the line chart would be:

Joe          .85      2022-06-20

Randy     .87      2022-06-20

Barb        .97      2022-05-14

 

I think I want to GroupBy the name column and then use AddColumns to populate the dataset with only the most recent record by date for each grouping but have been unable to figure out the proper syntax.

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @John_Sieber ,

You would need something like this

AddColumns(
   GroupBy(
      Sort(
         SPListName,
         'Result Date',
         Descending
      ),
      "Name",
      "Data"
   ),
   "ResultDate",
   First(Data).'Result Date',
   "Score",
   First(Data).Result
)

 also avoid calling columns Reserved Words such as Result - it can cause ambiguity

 

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

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @John_Sieber ,

You would need something like this

AddColumns(
   GroupBy(
      Sort(
         SPListName,
         'Result Date',
         Descending
      ),
      "Name",
      "Data"
   ),
   "ResultDate",
   First(Data).'Result Date',
   "Score",
   First(Data).Result
)

 also avoid calling columns Reserved Words such as Result - it can cause ambiguity

 

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

John_Sieber
New Member

@WarrenBelzthanks you very much.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,707)