Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
karthikeyan1504
Creator III
Creator III

Need help in filling missing year with records

jagan‌, sunindia‌, tresesco‌, swuehl‌, MRKachhiaIMP

Hi all,

I have staff table as shown below,

    

Staff NoNameDepartmentDate JoinedContract Expiry Date
19710MarkInsurance30/4/201330/6/2015
30665RossRetail6/6/201230/6/2014
36698MikeMarketing23/5/201430/6/2016

Based on the Date Joined and Contract expiry date, I need add the years between them. In short I need one more column with all the years from joined and expiry date as shown below,

     

Staff NoNameDepartmentDate JoinedContract Expiry DateYear
19710MarkInsurance30/4/201330/6/20152013/2014
19710MarkInsurance30/4/201330/6/20152014/2015
30665RossRetail6/6/201230/6/20132012/2013
30665RossRetail6/6/201230/6/20132013/2014
30665RossRetail6/6/201230/6/20132014/2015
36698MikeMarketing23/5/201430/6/20162014/2015
36698MikeMarketing23/5/201430/6/20162015/2016

Could anyone please help me on this?

Thanks & Regards,

Karthikeyan.

1 Solution

Accepted Solutions
t_chetirbok
Creator III
Creator III

Hi!

here just a little modify file

View solution in original post

5 Replies
senpradip007
Specialist III
Specialist III

Have a look at this.

karthikeyan1504
Creator III
Creator III
Author

Thanks for your response. But I am getting only start year and end year from your solurtion. I need to have all the years in between joined and expiry date.

t_chetirbok
Creator III
Creator III

Hi!

here just a little modify file

tamilarasu
Champion
Champion

Hi,

Try,

T1:

Load *, Year([Date Joined]) as JoinedYear, Year( [Contract Expiry Date]) as ExpiryYear;

LOAD * INLINE [

Staff No, Name, Department, Date Joined, Contract Expiry Date

    19710, Mark, Insurance, 30/4/2013, 30/6/2015

    30665, Ross, Retail, 6/6/2012, 30/6/2015

    36698, Mike, Marketing, 23/5/2014, 30/6/2016

];

T2:

load *, (JoinedYear + IterNo() -1) & '/' & (JoinedYear + IterNo()) as Year

Resident T1

While JoinedYear + IterNo() - 1 < ExpiryYear;

DROP Table T1;

Capture.PNG

settu_periasamy
Master III
Master III

Hi,

Try this..

SET DateFormat='D/M/YYYY';

Temp:
LOAD 2011+IterNo()-1 as Year AutoGenerate 1 While IterNo()<=10;

T1:
LOAD *,Year([Date Joined]) as doj_year,Year([Contract Expiry Date]) as ced_year;
LOAD * INLINE [
Staff No, Name, Department, Date Joined, Contract Expiry Date
19710, Mark, Insurance, 30/4/2013, 30/6/2015
30665, Ross, Retail, 6/6/2012, 30/6/2015
36698, Mike, Marketing, 23/5/2014, 30/6/2016
]
;

Inner Join(Temp)

IntervalMatch (Year) LOAD doj_year,ced_year Resident T1;

Left Join (T1)
LOAD * Resident Temp;

DROP Table Temp;

NoConcatenate
Final:
LOAD [Staff No],
Name, Department,
[Date Joined],
[Contract Expiry Date],Previous(Year)&' / '&Year as New
Resident T1 where AutoNumber(RecNo(),[Staff No])<>1 Order by [Staff No],[Date Joined] ;

DROP Table T1;

Capture.JPG