Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My data looks like this...
| Year | Month | Year_Month | Emp_ID | YR_MO_EID_Key | Business Unit |
|---|---|---|---|---|---|
| 2011 | 12 | 201112 | 1001 | 2011121001 | ENT |
2011 | 12 | 201112 | 1002 | 2011121002 | SMB |
| 2012 | 1 | 201201 | 1001 | 2012011001 | ENT |
| 2012 | 1 | 201201 | 1002 | 2012011002 | FND |
| 2012 | 1 | 201201 | 1003 | 2012011002 | ENT |
| 2012 | 2 | 201202 | 1001 | 2012021001 | SMB |
| 2012 | 2 | 201202 | 1002 | 2012021002 | FND |
| 2012 | 2 | 201202 | 1003 | 2012021003 | SMB |
...and I want to make a bar chart that shows the number of employees that have transferred into a business unit by month. A table of this output would look like this...
| Month | ENT | SMB | FND |
|---|---|---|---|
| DEC-11 | - | - | - |
| JAN-12 | 0 | 0 | 1 |
| FEB-12 | 0 | 2 | 0 |
The first row is empty because there is no data prior to DEC-11. Also, note that a new employee (1003) appears in JAN-12. This new employee should not count as a transfer into a business unit. If an employee stays in a business unit, that also should not count as a transfer into that business unit. For a given month and for a given business unit, I only want to count the number of employees that a) existed in the previous month and b) changed business units to the given business unit. How can I do this and put the monthly numbers in a bar chart?
You need to create a field in the load script as a flag whether the employee is trasferred or not.
like
Load *, if(peek('Emp_ID') = Emp_ID and peek('BusinessUnit') <> BusinessUnit , 1, 0) AS IsTransferred;
Load
Year,Month,Year_Month,Emp_ID,YR_MO_EID_Key,BusinessUnit
From ...
Order by Year_Month,Emp_ID;
Then expression as
Sum(IsTransferred)