Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MK9885
Master II
Master II

Insert dummy records/fetch latest date

Hi,

I've a requirement where I need to fetch the latest Supervisor for a given Emp.

Below are 2 tables

EMP01 in his period has 3 different supervisors but I only need to show the latest Supervisor (which would be EMP04 for EMP01)

I used different kind of set functions to do this but doesn't exactly works.....

The default count view of a chart should show only the count for last month of every year (Dec, YYYY) and rest other months are invalid for an employee.

@Sunny Talwar

shraddha.g

lakshmikandh

EMPTABLE:  

EMP KEYEMPLIDNAMESTART DTEND DTROW
21001EMP011/1/20141/1/2015N
71001EMP011/2/201512/30/2015Y
31001EMP0112/31/201512/31/9999 N
41002EMP021/1/200012/31/9999Y
51003EMP031/1/201510/30/2015Y
61004EMP0412/31/201512/31/9999Y

SUPTABLE: 

EMPLIDSUPV IDSTART DTEND DTSUPVNAME
100110021/1/20147/1/2014EMP02
100110037/2/201412/30/2015EMP03
1001100412/31/201512/31/9999EMP04
1 Solution

Accepted Solutions
sunny_talwar

May be like this

SUPTABLE:

LOAD EMPLID,

     FirstSortedValue([SUPV ID], -[START DT]) as [SUPV ID],

     Max([START DT]) as [START DT],

     Max([END DT]) as [END DT],

     FirstSortedValue(SUPVNAME, -[START DT]) as SUPVNAME

Resident ....

Group By [EMPLID];

View solution in original post

7 Replies
sunny_talwar

May be like this

SUPTABLE:

LOAD EMPLID,

     FirstSortedValue([SUPV ID], -[START DT]) as [SUPV ID],

     Max([START DT]) as [START DT],

     Max([END DT]) as [END DT],

     FirstSortedValue(SUPVNAME, -[START DT]) as SUPVNAME

Resident ....

Group By [EMPLID];

MK9885
Master II
Master II
Author

Thanks,

In a way I got it but there is actually more to it....

As in the record should be fetched for only Dec and rest all the records should be ignored for that Employee.

It is working with the sample data, I hope it will work with full load as well.....

But thanks a lot .

MK9885
Master II
Master II
Author

One more question..

What expression would I need to get only one bar. As only 1 Emp is having active Manager for end date as 12/31/9999

I tried

count({<[END DT] = {'$(=Max([END DT]))'}>} DISTINCT(NAME))

and it gives me bars for 2014 and 2015 as well

[END DT] is new field we got from resident load.

sunny_talwar

May be [END DT] is not formatted as date? Not sure, can you share a sample?

MK9885
Master II
Master II
Author

The END DATE is in Date format...

But you can verify

Please find the attachment

Thanks.

sunny_talwar

Here is why you see 2014 and 2015

Capture.PNG

MK9885
Master II
Master II
Author

Yeah but how do I fetch only the latest year (2015) for given Emp and Supervisor?

Cus those 2 dates are for same supervisor but one is his start date in 2014 and other is related to Emp Date