<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Interval Match in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Interval-Match/m-p/1208280#M387976</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am building a data model of employee shifts, so at any hour the application will reveal what department they are in.&amp;nbsp; I have a single column of clock in times, and another column that gives the legend for the type of clock in, in, out, and startshift.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I've done so far, I broke out the times to determine which is a start time and end time.&amp;nbsp; The idea was to use interval match to find out how many were on staff at any given hour.&amp;nbsp; I build out the calendar and the date hour field does not work.&amp;nbsp; When I broke out my start shift and stop shift from the singe column, when I loaded the data into a table box, either the start time or stop time is null.&amp;nbsp; So if an employee clock in once, it will show like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The employee shift times is in one column like this.&lt;/P&gt;&lt;P&gt;1/01/20116 8:00 am&lt;/P&gt;&lt;P&gt;01/01/2016 5:00 pm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Kindly for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start time&amp;nbsp;&amp;nbsp;&amp;nbsp; end time&lt;/P&gt;&lt;P&gt;9 am&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5pm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the script:&lt;/P&gt;&lt;P&gt;Shift:&lt;/P&gt;&lt;P&gt;Load Distinct&lt;/P&gt;&lt;P&gt;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(Match(Shift_Flg, 'ClockIn'),date(EmployeePunchDateTime,'MM/DD/YYYY hh:mm' )) AS [ShiftStart],&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(Match(Shift_Flg, 'ClockOut'),date(EmployeePunchDateTime, 'MM/DD/YYYY hh:mm' )) AS [ShiftEnd]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp; EmployeeNumber,&lt;/P&gt;&lt;P&gt;&amp;nbsp; PUNCHDTM as EmployeePunchDateTime,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(floor(PUNCHDTM)) AS EmployeePunchDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp(floor(PUNCHDTM) + Maketime(hour(PUNCHDTM)), 'MM/DD/YYYY hh') as ShiftHour,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Time(PUNCHDTM) as EmployeePunchTime,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(PUNCHOVERRIDE='New Shift' or PUNCHOVERRIDE='NULL' or PUNCHOVERRIDE='In Punch', dual('ClockIn',1),dual('ClockOut',0)) as Shift_Flg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PUNCHOVERRIDE as EmployeePunchStatus&lt;/P&gt;&lt;P&gt;Resident Employee;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date_temp:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; min(floor(ShiftStart)) as mindate,&lt;/P&gt;&lt;P&gt;&amp;nbsp; max(floor(ShiftEnd)) as maxdate&lt;/P&gt;&lt;P&gt;RESIDENT Shift;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;LET vMindate = peek('mindate')-1;&lt;/P&gt;&lt;P&gt;LET vMaxdate = peek('maxdate');&lt;/P&gt;&lt;P&gt;DROP TABLE date_temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 0 to 23 // Hour 0 to 23&lt;/P&gt;&lt;P&gt;&amp;nbsp; Calendar:&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; timestamp(Date + Maketime($(i)), 'MM/DD/YYYY hh') as DateHour,&lt;/P&gt;&lt;P&gt;&amp;nbsp; $(i) as Hour&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; date($(vMindate) + IterNo()) as Date&lt;/P&gt;&lt;P&gt;&amp;nbsp; AUTOGENERATE 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHILE $(vMindate) + IterNo() &amp;lt;= $(vMaxdate)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left join(Shift)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IntervalMatch (DateHour)&lt;/P&gt;&lt;P&gt;LOAD ShiftStart, ShiftEnd&lt;/P&gt;&lt;P&gt;RESIDENT Shift&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Nov 2016 08:59:55 GMT</pubDate>
    <dc:creator>detmawin</dc:creator>
    <dc:date>2016-11-04T08:59:55Z</dc:date>
    <item>
      <title>Interval Match</title>
      <link>https://community.qlik.com/t5/QlikView/Interval-Match/m-p/1208280#M387976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am building a data model of employee shifts, so at any hour the application will reveal what department they are in.&amp;nbsp; I have a single column of clock in times, and another column that gives the legend for the type of clock in, in, out, and startshift.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I've done so far, I broke out the times to determine which is a start time and end time.&amp;nbsp; The idea was to use interval match to find out how many were on staff at any given hour.&amp;nbsp; I build out the calendar and the date hour field does not work.&amp;nbsp; When I broke out my start shift and stop shift from the singe column, when I loaded the data into a table box, either the start time or stop time is null.&amp;nbsp; So if an employee clock in once, it will show like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The employee shift times is in one column like this.&lt;/P&gt;&lt;P&gt;1/01/20116 8:00 am&lt;/P&gt;&lt;P&gt;01/01/2016 5:00 pm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Kindly for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start time&amp;nbsp;&amp;nbsp;&amp;nbsp; end time&lt;/P&gt;&lt;P&gt;9 am&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5pm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the script:&lt;/P&gt;&lt;P&gt;Shift:&lt;/P&gt;&lt;P&gt;Load Distinct&lt;/P&gt;&lt;P&gt;&amp;nbsp; *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(Match(Shift_Flg, 'ClockIn'),date(EmployeePunchDateTime,'MM/DD/YYYY hh:mm' )) AS [ShiftStart],&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(Match(Shift_Flg, 'ClockOut'),date(EmployeePunchDateTime, 'MM/DD/YYYY hh:mm' )) AS [ShiftEnd]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp; EmployeeNumber,&lt;/P&gt;&lt;P&gt;&amp;nbsp; PUNCHDTM as EmployeePunchDateTime,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(floor(PUNCHDTM)) AS EmployeePunchDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp(floor(PUNCHDTM) + Maketime(hour(PUNCHDTM)), 'MM/DD/YYYY hh') as ShiftHour,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Time(PUNCHDTM) as EmployeePunchTime,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(PUNCHOVERRIDE='New Shift' or PUNCHOVERRIDE='NULL' or PUNCHOVERRIDE='In Punch', dual('ClockIn',1),dual('ClockOut',0)) as Shift_Flg,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PUNCHOVERRIDE as EmployeePunchStatus&lt;/P&gt;&lt;P&gt;Resident Employee;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date_temp:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; min(floor(ShiftStart)) as mindate,&lt;/P&gt;&lt;P&gt;&amp;nbsp; max(floor(ShiftEnd)) as maxdate&lt;/P&gt;&lt;P&gt;RESIDENT Shift;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;LET vMindate = peek('mindate')-1;&lt;/P&gt;&lt;P&gt;LET vMaxdate = peek('maxdate');&lt;/P&gt;&lt;P&gt;DROP TABLE date_temp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOR i = 0 to 23 // Hour 0 to 23&lt;/P&gt;&lt;P&gt;&amp;nbsp; Calendar:&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; timestamp(Date + Maketime($(i)), 'MM/DD/YYYY hh') as DateHour,&lt;/P&gt;&lt;P&gt;&amp;nbsp; $(i) as Hour&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; date($(vMindate) + IterNo()) as Date&lt;/P&gt;&lt;P&gt;&amp;nbsp; AUTOGENERATE 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHILE $(vMindate) + IterNo() &amp;lt;= $(vMaxdate)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;NEXT i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left join(Shift)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IntervalMatch (DateHour)&lt;/P&gt;&lt;P&gt;LOAD ShiftStart, ShiftEnd&lt;/P&gt;&lt;P&gt;RESIDENT Shift&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 08:59:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Interval-Match/m-p/1208280#M387976</guid>
      <dc:creator>detmawin</dc:creator>
      <dc:date>2016-11-04T08:59:55Z</dc:date>
    </item>
  </channel>
</rss>

