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:
Employee | Items |
John | 2 |
Scott | 1 |
Is this possible without any delegation limits.
Solved! Go to Solution.
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
@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.
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
@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.
@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.🤔
User | Count |
---|---|
162 | |
95 | |
77 | |
72 | |
58 |
User | Count |
---|---|
216 | |
166 | |
97 | |
96 | |
74 |