Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
salto
Specialist II
Specialist II

Split StartDate and EndDate in monthly view

Hello,

I have a table like this:

EmployeeContract_IDStartDateEndDateHours/day
AC115/03/2010

20/03/2010

8
AC224/03/201030/06/20106
BC301/03/201004/05/20107

For a monthly analysis of the worked hours, I would like to convert it to a data-model like the one below, in which a monthly sum of worked hours is made for every employee:

EmployeeContract_IDYearMonthHours
AC12010348 (result of 6 days * 8 hours/day)
AC22010342 (result of 7 days * 8 hours/day)
AC22010430*6
AC22010531*6
AC22010630*6
BC32010331*7
BC32010430*7
BC3201054*7

I would need to create a new record in the resulting table for every employee, contract_ID and month between the starting and ending date, including these dates' months.

Any help in this matter will be highly appreciated.

Many thanks in advance.

1 Solution

Accepted Solutions
Anonymous
Not applicable

See the attached.

View solution in original post

5 Replies
Not applicable

Hi Salto,

maybe have a look at interval match IntervalMatch

should be able to use that to generate the required rows that you need

hope that helps

Joe

Anonymous
Not applicable

See the attached.

maxgro
MVP
MVP

1.png


source:

LOAD Employee,

     Contract_ID,

     StartDate,

     EndDate,

     [Hours/day]

FROM

[https://community.qlik.com/thread/159862]

(html, codepage is 1252, embedded labels, table is @1);

tmp:

load

  *,

  date(StartDate + IterNo() -1) as Date

Resident

  source

While StartDate + IterNo()-1 <= EndDate ;

final:

load Employee,

     Contract_ID,

     Year(Date) as y,

     Month(Date) as m,

     sum([Hours/day]) as [Hours/day]

resident tmp

group by  Employee,

     Contract_ID,

     Year(Date) ,Month(Date);

DROP Table tmp, source;

salto
Specialist II
Specialist II
Author

Hi,

this is exactly what I was looking for.

Many thanks!

salto
Specialist II
Specialist II
Author

Hi Massimo,

It does not exactly give me the result I was looking for, but many thanks for your script.