Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Need help on table expression.

Hi All,

I have some month end data on employees, which looks like below. I need to find employees that are at or above Average Retirement age, in a given year(YTD).

Wrk_cnt = 1, if employee is active as of that month end

Retirement = 1, if employee retired that month. If they retire, there will be no row for that emplid next month.

   

MONTH_END_DTEMPLIDAge as of Year endRetirement WRK_COUNT
1/31/201400015401
2/28/201400015401
3/31/201400015401
4/30/201400015401
5/31/201400015401
6/30/201400015401
7/31/201400015401
8/31/201400015401
9/30/201400015401
10/31/201400015401
11/30/201400015401
12/31/201400015401
1/31/201500015501
2/28/201500015501
3/31/201500015501
4/30/201500015501
5/31/201500015501
6/30/201500015501
7/31/201500015501
8/31/201500015501
9/30/201500015501
10/31/201500015501
11/30/201500015501
12/31/201500015501
1/31/201600015601
2/29/201600015601
3/31/201600015601
4/30/201600015601
5/31/201600015601
6/30/201600015601
7/31/201600015601
8/31/201600015601
9/30/201600015601
10/31/201600015601
11/30/201600015601
12/31/201600015601
1/31/201700015710
1/31/201500025001
2/28/201500025001
3/31/201500025001
4/30/201500025001
5/31/201500025001
6/30/201500025001
7/31/201500025001
8/31/201500025001
9/30/201500025001
10/31/201500025001
11/30/201500025001
12/31/201500025001
1/31/201600025101
2/29/201600025101
3/31/201600025101
4/30/201600025101
5/31/201600025101
6/30/201600025101
7/31/201600025101
8/31/201600025101
9/30/201600025101
10/31/201600025101
11/30/201600025101
12/31/201600025101

Avg Age at retirement =Sum(if((Year([MONTH_END_DT])=Year([InputDateVar])or Year([MONTH_END_DT])=Year(YearVar1) or Year([MONTH_END_DT])=Year(YearVar2) or Year([MONTH_END_DT])=Year(YearVar3) or Year([MONTH_END_DT])=Year(YearVar4) or Year([MONTH_END_DT])=Year(YearVar5) or Year([MONTH_END_DT])=Year(YearVar6) or Year([MONTH_END_DT])=Year(YearVar7)) and [Retirement ]=1,[EMPL_AGE],0))/
Sum(if((Year([MONTH_END_DT])=Year([InputDateVar]) or Year([MONTH_END_DT])=Year(YearVar1) or Year([MONTH_END_DT])=Year(YearVar2) or Year([MONTH_END_DT])=Year(YearVar3) or Year([MONTH_END_DT])=Year(YearVar4) or Year([MONTH_END_DT])=Year(YearVar5) or Year([MONTH_END_DT])=Year(YearVar6) or Year([MONTH_END_DT])=Year(YearVar7)),[Retirement ],0))


InputDateVar = MONTH_END_DT selected from Input box. Input box contains all distinct values of month end dt present in data.

YearVar1 = AddMonths(InputDateVar,-Month(InputDateVar),1)

YearVar2 = =AddMonths(YearVar1,-12,1) and so on...

At or above average age of retirement = Sum(WRK_COUNT) , for age is greater than or equal to Avg age of retirement. I want a table like below. But not able to calculate rightmost column. Could someone please help.

YEAR

Headcount

Retirement Rate

Average Age at Retirement

At or above Average age at retirement

2011

32000

2.17%

59.60

2012

31000

2.07%

60.04

2013

31200

1.97%

59.27

2014

32003

2.27%

59.07

2015

32050

2.20%

60.06

   

1 Reply
Anonymous
Not applicable
Author

Hi Ekta Rathi,

Could you please try the below logic with set analysis

sum({$<WRK_COUNT={1}>,Mon_END_DT}

OR (E{$<Retirement={1}>,EMPLID}))

Thanks Regards,

Ramesh.P