Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Community, if there are other threads that can answer my question please provide me a link.
What I am trying to archive as per the two tables of Staff and Branch below is find an expression that can calculate the number of colleagues each staff has per the branch they work for.
I would like to archive something similar to the green table in the picture.
May be this?
Staff:
LOAD * Inline [
StaffID, StaffName, BranchID, SalesQuota
1, John Doe, 1, 1000
2, Sally Tom, 2, 2000
3, Petter Sam, 1, 1000
4, James Ken, 1, 1000
];
Left Join (Staff)
LOAD BranchID,
Count(StaffID) - 1 as NumberOfColleagues
Resident Staff
Group By BranchID;
Staff:
Load * Inline [
StaffID, StaffName, BranchID, SalesQuota
1, John Doe, 1, 1000
2, Sally Tom, 2, 2000
3, Peter Sam, 1, 1000
4, James Ken, 1, 1000
];
left join(Staff)
Branch:
Load * Inline [
BranchID, BranchName
1, B1
2, B2
];
left join(Staff)
Count:
Load BranchID, count(StaffID)-1 as Count
Resident Staff
group by BranchID;
Thank you Sunny. Your solution works for me.
However is there a way to archive the same result via set analysis?
Not sure how this will play out with the real data, but try this:
=Aggr(Count(TOTAL <BranchID> BranchID), BranchID, StaffName) - Count(BranchID)
with StaffName as the dimension