Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help for writing expression

Hi ,

I want to write expression as to how many employees are reporting to particular manager. If there  are no reportees then 0 should be displayed otherwise count of repotees should be displayed in straight chart..

Please help me ...

19 Replies
Not applicable
Author

Hi

PFA

as per your data eno: 1  has manager id , and eno2 should be 0 as there is no manager id

tyagishaila
Specialist
Specialist

Immediate Try this in your expression

if(MangerID='' ,'',count(TOTAL <MangerID>EmpName))

'' means NULL

Not applicable
Author

Please find the data

EMp:

LOAD * INLINE [

    EMPno, EmpName, MangerID

    1, A, 2

    2, B

    3, C, 4

    4, D, 2

    5, E, 4

    6, F, 5

];

and I want to show the result using straight chart

                          

EmpnoNo of Reportees
10
22
30
42
51
60

ManagerId will be same as the Empno

Not applicable
Author

Still not clear with your data

pfa

may helps you

tyagishaila
Specialist
Specialist

LOAD * INLINE [

    EmpNo, EmpName, MangerID

    1, A, 2

    2, B,

    3, C, 4

    4, D, 2

    5, E, 4

    6, F, 5

    7, S, 2

];

I find this Output and I thin this is okay,

there are 3 employees who report to managerID 2

similarly 2 employees report to managerID 4

What Output you exactly want.

Its not clear

tyagishaila
Specialist
Specialist

Plz share your complete data,

I think there are more information which is not clear to us,

tyagishaila
Specialist
Specialist

How can be no of reportees 0 for empno 1 ,

while empno 1 reports to ManagerID 2 and also empno 4 reports to managerID 2,

so for empno 1 there should be 2 no of reportees,

tresesco
MVP
MVP

A self-join would be useful, try like:

Input:
LOAD * INLINE [

    EMPno, EmpName, MangerID

    1, A, 2
    2, B
    3, C, 4
    4, D, 2
    5, E, 4
    6, F, 5

];
Left Join
Load
MangerID as EMPno,
EMPno as Manager
Resident Input;

PFA

Not applicable
Author

For Empno 1 is not in MgrId  so he won't be having any reportees so  count of Reprotees will be 0

similarly Empno 2 there are 3 employees reporting to him.. EmpNo  1,4,7 So count of Reprotees will be 3

Like wise for all employees    i want..

Is this clear now?

Not applicable
Author

Thank you very much  tresesco

Thanks all for your replies..