<?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 Problem with intervalmatch in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Problem-with-intervalmatch/m-p/2475039#M100078</link>
    <description>&lt;P&gt;Hi, I'm trying to use intervalmatch to connect to tables, one with production, by time and machine and other with shifts.&lt;/P&gt;
&lt;P&gt;The production table has a date and a timestamp for each record, the shifts table has the shift ID, start hour, end hour and machine.&lt;/P&gt;
&lt;P&gt;Here's the script I'm using&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Co_Mov:
//Events:
Load 
KEY_LINK_COD_DATA,
KEY_LINK_RECURSO,
Time(Frac(Hora_Fim/60/60)) as [Hora Produção],

Hora_Fim,
Qtd_Movimento_1
From [lib://Teste:DataFiles/Co_Mov_F1.qvd](qvd);


Dt_Turno:
//Shifts
load
KEY_LINK_RECURSO,
maketime(subfield(HIni_T1,':',1),subfield(HIni_T1,':',2),00) as HIni_T1,
maketime(subfield(HIni_T2,':',1),subfield(HIni_T2,':',2),00) as HFim_T1,
maketime(subfield(HIni_T2,':',1),subfield(HIni_T2,':',2),00) as HIni_T2,
maketime(subfield(HIni_T3,':',1),subfield(HIni_T3,':',2),00) as HFim_T2,
maketime(subfield(HIni_T3,':',1),subfield(HIni_T3,':',2),00) as HIni_T3,
maketime(subfield(HIni_T1,':',1),subfield(HIni_T1,':',2),00) as HFim_T3
;
 load
//empr_cod,
KEY_LINK_RECURSO,
Time#(tb_alfa1, 'hh:mm:ss')  as HIni_T1,
Time#(tb_alfa2, 'hh:mm:ss')  as HFim_T1,
Time#(tb_alfa2, 'hh:mm:ss')  as HIni_T2,
Time#(tb_alfa3, 'hh:mm:ss')  as HFim_T2,
Time#(tb_alfa3, 'hh:mm:ss')  as HIni_T3,
Time#(tb_alfa1, 'hh:mm:ss')  as HFim_T3
;
load 
empr_cod,
empr_cod &amp;amp; '|' &amp;amp; 'M' &amp;amp; '|' &amp;amp; tb_cod as KEY_LINK_RECURSO,
tb_alfa1,
//timestamp(tb_alfa1 + (8/24),'hh:mm') as HrFim,
TB_ALFA2 as tb_alfa2,
tb_alfa3
from [lib://Teste:DataFiles/MULTI_sb_tabvl.qvd](qvd)
WHERE tb_num = 9603;

//exit script;

 
b:
crosstable(Turno,HoraIni)
load
KEY_LINK_RECURSO,
HIni_T1 as T1,
HIni_T2 as T2,
HIni_T3 as T3
resident Dt_Turno;
//drop table Dt_Turno;


c:
crosstable(Turno,HoraFim)
load
KEY_LINK_RECURSO,
HFim_T1 as T1,
HFim_T2 as T2,
HFim_T3 as T3
resident Dt_Turno;
drop table Dt_Turno;


d:
Load
*,
1 as drop
resident b;

left join(d)
load
*
resident c;

drop table b;
drop table c;
drop field drop;

//exit script;

IntervalMatch:
IntervalMatch ([Hora Produção],KEY_LINK_RECURSO)
Load distinct HoraIni, HoraFim,KEY_LINK_RECURSO resident d;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the output (please note that the record for the "Hora Produção" = 1:08:24PM should only be associated with Shift T1 but it's associated with all 3 shifts:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andrefpc_0-1723031950559.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/170324iBE09CF18036016CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="andrefpc_0-1723031950559.png" alt="andrefpc_0-1723031950559.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In this table I have:&lt;/P&gt;
&lt;P&gt;KEY_LINK_RESOURCE = MachineID&lt;/P&gt;
&lt;P&gt;Turno = Shift description&lt;/P&gt;
&lt;P&gt;HoraIni = shift start time&lt;/P&gt;
&lt;P&gt;HoraFim = shift end time&lt;/P&gt;
&lt;P&gt;KEY_LINK_COD_DATA = production date&lt;/P&gt;
&lt;P&gt;Sum(Qtd_Movimento_1) = produced quantity&lt;/P&gt;
&lt;P&gt;Hora Produção = production time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible that the problem comes from the number formatting?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Aug 2024 12:05:03 GMT</pubDate>
    <dc:creator>andrefpc</dc:creator>
    <dc:date>2024-08-07T12:05:03Z</dc:date>
    <item>
      <title>Problem with intervalmatch</title>
      <link>https://community.qlik.com/t5/App-Development/Problem-with-intervalmatch/m-p/2475039#M100078</link>
      <description>&lt;P&gt;Hi, I'm trying to use intervalmatch to connect to tables, one with production, by time and machine and other with shifts.&lt;/P&gt;
&lt;P&gt;The production table has a date and a timestamp for each record, the shifts table has the shift ID, start hour, end hour and machine.&lt;/P&gt;
&lt;P&gt;Here's the script I'm using&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Co_Mov:
//Events:
Load 
KEY_LINK_COD_DATA,
KEY_LINK_RECURSO,
Time(Frac(Hora_Fim/60/60)) as [Hora Produção],

Hora_Fim,
Qtd_Movimento_1
From [lib://Teste:DataFiles/Co_Mov_F1.qvd](qvd);


Dt_Turno:
//Shifts
load
KEY_LINK_RECURSO,
maketime(subfield(HIni_T1,':',1),subfield(HIni_T1,':',2),00) as HIni_T1,
maketime(subfield(HIni_T2,':',1),subfield(HIni_T2,':',2),00) as HFim_T1,
maketime(subfield(HIni_T2,':',1),subfield(HIni_T2,':',2),00) as HIni_T2,
maketime(subfield(HIni_T3,':',1),subfield(HIni_T3,':',2),00) as HFim_T2,
maketime(subfield(HIni_T3,':',1),subfield(HIni_T3,':',2),00) as HIni_T3,
maketime(subfield(HIni_T1,':',1),subfield(HIni_T1,':',2),00) as HFim_T3
;
 load
//empr_cod,
KEY_LINK_RECURSO,
Time#(tb_alfa1, 'hh:mm:ss')  as HIni_T1,
Time#(tb_alfa2, 'hh:mm:ss')  as HFim_T1,
Time#(tb_alfa2, 'hh:mm:ss')  as HIni_T2,
Time#(tb_alfa3, 'hh:mm:ss')  as HFim_T2,
Time#(tb_alfa3, 'hh:mm:ss')  as HIni_T3,
Time#(tb_alfa1, 'hh:mm:ss')  as HFim_T3
;
load 
empr_cod,
empr_cod &amp;amp; '|' &amp;amp; 'M' &amp;amp; '|' &amp;amp; tb_cod as KEY_LINK_RECURSO,
tb_alfa1,
//timestamp(tb_alfa1 + (8/24),'hh:mm') as HrFim,
TB_ALFA2 as tb_alfa2,
tb_alfa3
from [lib://Teste:DataFiles/MULTI_sb_tabvl.qvd](qvd)
WHERE tb_num = 9603;

//exit script;

 
b:
crosstable(Turno,HoraIni)
load
KEY_LINK_RECURSO,
HIni_T1 as T1,
HIni_T2 as T2,
HIni_T3 as T3
resident Dt_Turno;
//drop table Dt_Turno;


c:
crosstable(Turno,HoraFim)
load
KEY_LINK_RECURSO,
HFim_T1 as T1,
HFim_T2 as T2,
HFim_T3 as T3
resident Dt_Turno;
drop table Dt_Turno;


d:
Load
*,
1 as drop
resident b;

left join(d)
load
*
resident c;

drop table b;
drop table c;
drop field drop;

//exit script;

IntervalMatch:
IntervalMatch ([Hora Produção],KEY_LINK_RECURSO)
Load distinct HoraIni, HoraFim,KEY_LINK_RECURSO resident d;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the output (please note that the record for the "Hora Produção" = 1:08:24PM should only be associated with Shift T1 but it's associated with all 3 shifts:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="andrefpc_0-1723031950559.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/170324iBE09CF18036016CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="andrefpc_0-1723031950559.png" alt="andrefpc_0-1723031950559.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In this table I have:&lt;/P&gt;
&lt;P&gt;KEY_LINK_RESOURCE = MachineID&lt;/P&gt;
&lt;P&gt;Turno = Shift description&lt;/P&gt;
&lt;P&gt;HoraIni = shift start time&lt;/P&gt;
&lt;P&gt;HoraFim = shift end time&lt;/P&gt;
&lt;P&gt;KEY_LINK_COD_DATA = production date&lt;/P&gt;
&lt;P&gt;Sum(Qtd_Movimento_1) = produced quantity&lt;/P&gt;
&lt;P&gt;Hora Produção = production time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible that the problem comes from the number formatting?&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 12:05:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Problem-with-intervalmatch/m-p/2475039#M100078</guid>
      <dc:creator>andrefpc</dc:creator>
      <dc:date>2024-08-07T12:05:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with intervalmatch</title>
      <link>https://community.qlik.com/t5/App-Development/Problem-with-intervalmatch/m-p/2505669#M103997</link>
      <description>&lt;P&gt;I haven't gone through all the logics, but a common problem with crosstable is that all columns become text. If you are trying to match a number with text, you will get into trouble. Could that be it?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 20:33:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Problem-with-intervalmatch/m-p/2505669#M103997</guid>
      <dc:creator>morgankejerhag</dc:creator>
      <dc:date>2025-02-12T20:33:26Z</dc:date>
    </item>
  </channel>
</rss>

