cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Blacksmith354
Frequent Visitor

Count items in list grouped by a column

I'd like to count the SharePoint list items based on a column.

 

Employee
John
Scott
John

 

I'd like to visualize this in a data table like this:

 

EmployeeItems
John2
Scott1

 

Is this possible without any delegation limits.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
vermaaman
Resolver I
Resolver I

Assuming you are using DataTable control. 


You can use AddColumn & GroupBy function to achieve this. I have tried this formula and it worked for me.

AddColumns(
    GroupBy(
        SPOList,
        "Employees",
        "ID"
    ),
    "Count",
    CountRows(ThisRecord.ID)
)

 

Progressing?  Thumbs Up
Resolved your problem?  Accept as Solution

Helped others as well ?  Accept as Solution

View solution in original post

CNT
Super User
Super User

@Blacksmith354 Use the following formula

ClearCollect(colEmployeeCount, AddColumns(GroupBy(EmployeeList, "Employee", "EmployeeGroup" ), "EmployeeCount", CountRows(EmployeeGroup)))

 But remember GroupBy is not delegable. To avoid that you can filter the data before grouping. If that's not an option, collect all the data into a collection before applying the GroupBy.

View solution in original post

4 REPLIES 4
vermaaman
Resolver I
Resolver I

Assuming you are using DataTable control. 


You can use AddColumn & GroupBy function to achieve this. I have tried this formula and it worked for me.

AddColumns(
    GroupBy(
        SPOList,
        "Employees",
        "ID"
    ),
    "Count",
    CountRows(ThisRecord.ID)
)

 

Progressing?  Thumbs Up
Resolved your problem?  Accept as Solution

Helped others as well ?  Accept as Solution

View solution in original post

CNT
Super User
Super User

@Blacksmith354 Use the following formula

ClearCollect(colEmployeeCount, AddColumns(GroupBy(EmployeeList, "Employee", "EmployeeGroup" ), "EmployeeCount", CountRows(EmployeeGroup)))

 But remember GroupBy is not delegable. To avoid that you can filter the data before grouping. If that's not an option, collect all the data into a collection before applying the GroupBy.

View solution in original post

Blacksmith354
Frequent Visitor

@vermaaman  and @CNT thank you both. I guess I wasn't specific enough with my request and what exactly I'm trying to do, my apologies.

 

This worked, but now I can't filter records based on the date column. I'd like to have a count of items but be able to filter based on dates. If I'm using a dropdown of the distinct dates, how can I use this?

@Blacksmith354 Use the following formula to filter by date before grouping.

ClearCollect(colEmployeeCount, AddColumns(GroupBy(Filter(EmployeeList, myDate=Now()), "Employee", "EmployeeGroup" ), "EmployeeCount", CountRows(EmployeeGroup)))

Replace myDate with the data column in your SP list and Now() by the date you want to filter. E.g. if the user is selecting a date from a data picker, you can say DatePicker1.SelectedDate.

Hope that helps.🤔 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,315)