Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
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 ...

1 Solution

Accepted Solutions
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

View solution in original post

19 Replies
tresesco
MVP
MVP

Like this?

Dimension: manager

Exp: Count( Distinct employees)

jyothish8807
Master II
Master II

Hi Lokeshwari,

You can try what tresesco have suggested or you can use Aggr function in complex case. Can you share your app? It will be helpful to understand better.

Regards

KC

Best Regards,
KC
tyagishaila
Specialist
Specialist

Hi Lokeshwari,

You can do it by using Pivot table,

Dim1: ManagerName

Dim2: EmployeeName

Expression: count(EmployeeName)

and apply show partial sum on Dim2,

Try it

Not applicable
Author

may this helps you


if(Count( Distinct employees)>0,Count( Distinct employees),0)



tyagishaila
Specialist
Specialist

Hi,

For Straight Table,

Dim1: Manager

Dim2: Employee

Exp is

count(Total <Manger>Employee)

And for Null or Missing Values, Change '-' into 0 in Properties->Presentation

I am sure it will work

khalander
Creator II
Creator II

Hi,

Use AGGR() it will work .

aggr( distinct count(empID), MngrID)


Regards,

khalander

Not applicable
Author

But still it is not giving correct value...   I  have an example  as below

EMp:

LOAD * INLINE [

    EMPno, EmpName, MangerID

    1, A, 2

    2, B

    3, C, 4

    4, D, 2

    5, E, 4

    6, F, 5

];

But in chart when i applied the  expression it is  coming like this

For Empno--1 Reportees 0 should come but it is diplaying as 1

Not applicable
Author

But It  is not working  .Here is  my data  in script

EMp:

LOAD * INLINE [

    EMPno, EmpName, MangerID

    1, A, 2

    2, B

    3, C, 4

    4, D, 2

    5, E, 4

    6, F, 5

];

For example for  Empno-1 the number of reportees should come 0 since  he is not manager to any of the

employees..

jyothish8807
Master II
Master II

try:

if(len(trim(Reporte))>0,count(Reporte),0)

Regards

KC

Best Regards,
KC