Hello,
I am creating a kind of lookup table where a person will enter Employee Name and the table should show total salary of his department and company also. Here is an example data and what i wanted to see.
Tables i have in qlik sense: These two are totally independent tables
(complicated to explain y they are independent, not a big deal for now)
TABLE 1 | ||
EMP_NAME | DEPARTMENT | Thi year SALARY |
ABC | IT | 500 |
DEF | DB | 600 |
GHI | IT | 400 |
JKL | IT | 100 |
MNO | HR | 500 |
TABLE 2 | |
DEPARTMENT_2 | NEXT YEAR REV |
IT | 1200 |
DB | 900 |
HR | 1000 |
- Now in a sheet, i have a variable to enter Emp name. i will enter ABC in the variable.
- I would like to get the following data as result:
Emp Name | Emp Total | Department | Department Total (This Year) | Dept Next Year Total | Company Total |
ABC | 500 | IT | 1000 | 1200 | 2100 |
I am having difficulty in achieving the final 3 columns.
3rd col : Dept Total - here Dept will vary based on what EMployee i am searching for.
4th col : Dept Next year : as this is independent table - i should give variable as DEPARTMENT_2 = {ABC's DEPARTMENT from Table 1}.. something like this
5th col: irrespective of my Employee name search, should always display total company wide numbers.
Appreciate your inputs, Thanks.
Dept Total:
sum(total {<
DEPARTMENT= P({<EMP_NAME = {"$(=vEmployee)"}>}) >} [Thi year SALARY])
Dept Nex Year Total:
sum({<
EMP_NAME = {"$(=vEmployee)"},
DEPARTMENT_2= P({<EMP_NAME = {"$(=vEmployee)"}>}DEPARTMENT) >} [NEXT YEAR REV])
Company Total:
sum(total [Thi year SALARY])
[TABLE 1]:
LOAD * inline [
EMP_NAME, DEPARTMENT, Thi year SALARY
ABC, IT, 500
DEF, DB, 600
GHI, IT, 400
JKL, IT, 100
MNO, HR, 500];
[TABLE 2]:
LOAD * inline [
DEPARTMENT_2, NEXT YEAR REV
IT, 1200
DB, 900
HR, 1000
];
LET vEmployee = 'ABC';