Dear Team, For a SPList, i am trying to group the employees by Department and then get the count of them. Sounds easy. But i have been trying to derive the formula, which is not giving me the expected result.
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 3 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 2 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 3 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 1 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 1 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 2 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 3 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 2 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 2 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 3 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 2 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 3 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 2 |
Employee2 | 651 | Information Technology | 11 | 3 | 2 | 2 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 2 |
Employee1 | 650 | Information Technology | 11 | 4 | 1 | 1 |
AddColumns(Distinct(Filter(SPList,HodFlag ="Completed"),EmpDept),"CountDept",CountRows(Distinct(Filter(SPList,HodFlag ="Completed"),EmpDept)
my gallery should show me something like this. But i am getting count as 1 instead of 2.
There are two employees in Information Technology. So gallery rows will be displaying Department Names, and the Employee count on it.
You can ignore the HOD flag column as i have just made this column to make sure this record is verified by head of the department.
Later tried the formula.
AddColumns(GroupBy(AWPR_Responses,"EmpDept","DeptGroup"),"EmpCount",CountRows(Distinct(ThisRecord.DeptGroup,EmpFullName)))
Giving me the result in the gallery as
Please help to validate it ?
thisrecord.deptgroup and saying deptgroup
thisrecord.deptgroup is something you need to use in forall it respresent single item
deptgroup is table.
Just for my understanding, is there any change between thisrecord.deptgroup and saying deptgroup alone ?
AddColumns(GroupBy(AWPR_Responses,"EmpDept","DeptGroup"),"EmpCount",CountRows(Distinct(DeptGroup,EmpFullName)))
this should do just change thisitem.deptgroup to deptgroup
Hi @venka91 ,
for example here is my employee data:
ClearCollect(
colEmployees,
Table(
{ EmployeeName: "John", Department: "HR", Salary: 50000 },
{ EmployeeName: "Jane", Department: "IT", Salary: 60000 },
{ EmployeeName: "Michael", Department: "Finance", Salary: 55000 },
{ EmployeeName: "Emily", Department: "IT", Salary: 62000 },
{ EmployeeName: "David", Department: "HR", Salary: 48000 },
{ EmployeeName: "Sara", Department: "Finance", Salary: 58000 },
{ EmployeeName: "Daniel", Department: "IT", Salary: 61000 }
)
)
and here is the formula to count the employee as per Department:
ClearCollect(
colDepartmentCounts,
AddColumns(
GroupBy(colEmployees, "Department", "Group"),
"Temp_Department",
Group,
"Temp_Count",
CountRows(Group)
)
)
here is the output:
If this is the answer for your question, please mark the post as Solved.
If this answer helps you in any way, please give it a like.
WarrenBelz
791
Most Valuable Professional
MS.Ragavendar
410
Super User 2025 Season 2
mmbr1606
275
Super User 2025 Season 2