<?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 Re: Sum of Productive Runtime of Maschines in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879772#M72513</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/89478"&gt;@KarimBen&lt;/a&gt;&amp;nbsp; if I undersood correctly, you can use for example in script :&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;LOAD
    rowid as %rowid,
    date(left("timestamp",10)) as Datum ,
    mid("timestamp",12,8) as Zeit,
    "timestamp",
    tier1 as Grün,
    tier2 as Gelb,
    tier3 as Rot,
    if(tier1=0 and tier2=0 and tier3=0,1) as Counter,
    
    if(tier1=1,'läuft',
    if(tier1=0 and tier2=0 and tier3=0,'nicht produktiv',
    if(tier1=2, 'Schacht i.O. voll',
    if(tier2=1, 'Einrichten',
    if(tier2=2, 'Schacht nicht erfasst voll',
    if(tier3=1,  'Störung',
    if(tier3=2,  'Schacht n.i.O. voll'
    
    ))))))) as IndiCom,    
    "slaveref/refid",
    if("slaveref/macid"= '00A391','Brune4',
    if("slaveref/macid"= '00A399','Brune7')) as Slave,
    %Key_data_CD43325B85172CA2
    

FROM C:\Users\admin\Downloads\MDE_Export.xml
(XmlSimple, table is [data/slavestate])

;
LOAD
    rowid as %ROWID,
    state
FROM C:\Users\admin\Downloads\MDE_Export.xml
(XmlSimple, table is [data/sync])
where state= 'completed'
;

left join ([data/slavestate])
Load
%rowid,
if(IndiCom='läuft', mid("timestamp",12,8), null()) as ClockIn, 
if(IndiCom&amp;lt;&amp;gt;'läuft', mid("timestamp",12,8), null()) as ClockOut,
Datum&amp;amp;'_'&amp;amp;Slave as %Datum%Slave
// ,
// Interval( Time#(ClockOut,'hh:mm:ss TT')-Time#(ClockIn,'hh:mm:ss TT') ,'h') as RunT

Resident [data/slavestate];


left keep  ([data/slavestate])
Load 

//If(IndiCom='läuft',round((ClockOut-ClockIn)*1440,0.02,0 )) as ProdTime
sum((ClockOut -ClockIn))as RunTimeProd,
sum(Date(((ClockOut) - (ClockIn)),'hh:mm:ss')) as RunTimeProdFormat


Resident [data/slavestate]
group by %Datum%Slave, Slave, Datum
;

Data:
noconcatenate

load *,peek(IndiCom) as maschineStatus ,Time(Timestamp(Timestamp#(left(purgechar(timestamp,'T'),18),'YYYY-MM-DDhh:mm:ss'))-Timestamp(Timestamp#(left(purgechar(peek(timestamp),'T'),18),'YYYY-MM-DDhh:mm:ss'))) as maschineTime resident  [data/slavestate];

drop table [data/slavestate];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the in interface you can show this able :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_0-1641931115986.png"&gt;&lt;img src="https://community.qlik.com/skins/images/9BFAB5AA78DCF7C3BAFB6F364F3E50F2/responsive_peak/images/image_not_found.png" alt="Taoufiq_Zarra_0-1641931115986.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;or you can create this table :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_1-1641931152902.png"&gt;&lt;img src="https://community.qlik.com/skins/images/9BFAB5AA78DCF7C3BAFB6F364F3E50F2/responsive_peak/images/image_not_found.png" alt="Taoufiq_Zarra_1-1641931152902.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jan 2022 19:59:22 GMT</pubDate>
    <dc:creator>Taoufiq_Zarra</dc:creator>
    <dc:date>2022-01-11T19:59:22Z</dc:date>
    <item>
      <title>Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879043#M72471</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;i need your help please.&amp;nbsp;&lt;BR /&gt;We have several Maschines in our Production Line.&amp;nbsp;&lt;BR /&gt;We want to analyse the productivity of the Maschines.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The Maschine could different states and we want to sum the Time between the different States.&amp;nbsp;&lt;BR /&gt;For example State "Run" at 01:00:00 till State "fault" 01:30:00&amp;nbsp; that mean 0,5 h or 00:30:00 min productive.&amp;nbsp;&lt;BR /&gt;Attached you will my Script and a example Data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Work in Qliksense&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="lia-message-author-rank lia-component-author-rank lia-component-message-view-widget-author-rank"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Jan 2022 15:17:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879043#M72471</guid>
      <dc:creator>KarimBen</dc:creator>
      <dc:date>2022-01-10T15:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879502#M72493</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/89478"&gt;@KarimBen&lt;/a&gt;&amp;nbsp; can you elaborate ?&lt;/P&gt;
&lt;P&gt;from your sample :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_0-1641905461325.png"&gt;&lt;img src="https://community.qlik.com/skins/images/9BFAB5AA78DCF7C3BAFB6F364F3E50F2/responsive_peak/images/image_not_found.png" alt="Taoufiq_Zarra_0-1641905461325.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;can you share the expected output ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 12:51:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879502#M72493</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2022-01-11T12:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879658#M72503</link>
      <description>&lt;P&gt;Hello Taoufiq ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks for replying.&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;I want the sum of the individual status changes.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Thats it. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 16:03:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879658#M72503</guid>
      <dc:creator>KarimBen</dc:creator>
      <dc:date>2022-01-11T16:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879696#M72505</link>
      <description>&lt;P&gt;I want to Know how many time was the maschine "läuft" or "nicht produktiv" etc.&amp;nbsp;&lt;BR /&gt;I have Time Stamps Field Time and know i have to sum the Time between the changes of "Indicom".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 17:03:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879696#M72505</guid>
      <dc:creator>KarimBen</dc:creator>
      <dc:date>2022-01-11T17:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879772#M72513</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/89478"&gt;@KarimBen&lt;/a&gt;&amp;nbsp; if I undersood correctly, you can use for example in script :&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;LOAD
    rowid as %rowid,
    date(left("timestamp",10)) as Datum ,
    mid("timestamp",12,8) as Zeit,
    "timestamp",
    tier1 as Grün,
    tier2 as Gelb,
    tier3 as Rot,
    if(tier1=0 and tier2=0 and tier3=0,1) as Counter,
    
    if(tier1=1,'läuft',
    if(tier1=0 and tier2=0 and tier3=0,'nicht produktiv',
    if(tier1=2, 'Schacht i.O. voll',
    if(tier2=1, 'Einrichten',
    if(tier2=2, 'Schacht nicht erfasst voll',
    if(tier3=1,  'Störung',
    if(tier3=2,  'Schacht n.i.O. voll'
    
    ))))))) as IndiCom,    
    "slaveref/refid",
    if("slaveref/macid"= '00A391','Brune4',
    if("slaveref/macid"= '00A399','Brune7')) as Slave,
    %Key_data_CD43325B85172CA2
    

FROM C:\Users\admin\Downloads\MDE_Export.xml
(XmlSimple, table is [data/slavestate])

;
LOAD
    rowid as %ROWID,
    state
FROM C:\Users\admin\Downloads\MDE_Export.xml
(XmlSimple, table is [data/sync])
where state= 'completed'
;

left join ([data/slavestate])
Load
%rowid,
if(IndiCom='läuft', mid("timestamp",12,8), null()) as ClockIn, 
if(IndiCom&amp;lt;&amp;gt;'läuft', mid("timestamp",12,8), null()) as ClockOut,
Datum&amp;amp;'_'&amp;amp;Slave as %Datum%Slave
// ,
// Interval( Time#(ClockOut,'hh:mm:ss TT')-Time#(ClockIn,'hh:mm:ss TT') ,'h') as RunT

Resident [data/slavestate];


left keep  ([data/slavestate])
Load 

//If(IndiCom='läuft',round((ClockOut-ClockIn)*1440,0.02,0 )) as ProdTime
sum((ClockOut -ClockIn))as RunTimeProd,
sum(Date(((ClockOut) - (ClockIn)),'hh:mm:ss')) as RunTimeProdFormat


Resident [data/slavestate]
group by %Datum%Slave, Slave, Datum
;

Data:
noconcatenate

load *,peek(IndiCom) as maschineStatus ,Time(Timestamp(Timestamp#(left(purgechar(timestamp,'T'),18),'YYYY-MM-DDhh:mm:ss'))-Timestamp(Timestamp#(left(purgechar(peek(timestamp),'T'),18),'YYYY-MM-DDhh:mm:ss'))) as maschineTime resident  [data/slavestate];

drop table [data/slavestate];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the in interface you can show this able :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_0-1641931115986.png"&gt;&lt;img src="https://community.qlik.com/skins/images/9BFAB5AA78DCF7C3BAFB6F364F3E50F2/responsive_peak/images/image_not_found.png" alt="Taoufiq_Zarra_0-1641931115986.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;or you can create this table :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_1-1641931152902.png"&gt;&lt;img src="https://community.qlik.com/skins/images/9BFAB5AA78DCF7C3BAFB6F364F3E50F2/responsive_peak/images/image_not_found.png" alt="Taoufiq_Zarra_1-1641931152902.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 19:59:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879772#M72513</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2022-01-11T19:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879802#M72515</link>
      <description>&lt;P&gt;Hallo,&lt;/P&gt;
&lt;P&gt;another solution might be to resident load the machine runtime table sorted by slave and timestamp descending and calculate the duration of each machine state as difference between the current and previous timestamps.&lt;/P&gt;
&lt;P&gt;This way you don't have to aggregate on script level and might be more flexible in the analysis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;tabMaschinenLaufzeitenTemp:
LOAD rowid as %rowid,
     Date(Left(timestamp,10))	as Datum ,
     Mid(timestamp,12,8)		as Zeit,
     Timestamp#(Replace(Left(timestamp,26),'T',' '),'YYYY-MM-DD hh:mm:ss.fffffff') as DatumZeit,
     timestamp,
     tier1 						as Grün,
     tier2						as Gelb,
     tier3						as Rot,
     If(tier1=0 and tier2=0 and tier3=0,1) as Counter,
    
     If( tier1=1, 'läuft',
      If(tier1=0 and tier2=0 and tier3=0,'nicht produktiv',
      If(tier1=2, 'Schacht i.O. voll',
      If(tier2=1, 'Einrichten',
      If(tier2=2, 'Schacht nicht erfasst voll',
      If(tier3=1, 'Störung',
      If(tier3=2, 'Schacht n.i.O. voll'    
      ))))))) as IndiCom,
      
     If(tier1=1, Dual('läuft',1), Dual('läuft nicht',0)) as Lauf,
     
     [slaveref/refid],
      Pick(Match([slaveref/macid],'00A391','00A399'),'Brune4','Brune7') as Slave,
     %Key_data_CD43325B85172CA2
FROM [lib://C_Temp/MDE_Export.xml] (XmlSimple, table is [data/slavestate]);


tabMaschinenLaufzeiten:
LOAD *,
     If(Slave=Previous(Slave), Interval(Previous(DatumZeit)-DatumZeit)) as Dauer
Resident tabMaschinenLaufzeitenTemp
Order By Slave, %rowid desc;

DROP Table tabMaschinenLaufzeitenTemp;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_0-1641937572161.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/70034i765167F79B7A6E29/image-size/large?v=v2&amp;amp;px=999" role="button" title="MarcoWedel_0-1641937572161.png" alt="MarcoWedel_0-1641937572161.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarcoWedel_1-1641937587239.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/70035i8C4AC75EE9A41EB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="MarcoWedel_1-1641937587239.png" alt="MarcoWedel_1-1641937587239.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hope this helps&lt;/P&gt;
&lt;P&gt;Gruß&lt;/P&gt;
&lt;P&gt;Marco&lt;/P&gt;
&lt;P&gt;P.S.: Ich wusste gar nicht, dass WERMA auch etwas zur Datenerfassung des Ampelstatus im Angebot hat. Wieder etwas gelernt, danke.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 21:49:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879802#M72515</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2022-01-11T21:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of Productive Runtime of Maschines</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879818#M72519</link>
      <description>&lt;P&gt;Hello Taoufiq,&lt;BR /&gt;Hello Marco ,&amp;nbsp;&lt;BR /&gt;many thanks for the support.&lt;BR /&gt;Both solutions help me a lot.&amp;nbsp;&lt;BR /&gt;Very good community, love it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/675"&gt;@MarcoWedel&lt;/a&gt;&amp;nbsp; ja man kann Maschinen mit sensorik und slave von Werma nachrüsten,&amp;nbsp;&lt;BR /&gt;diese Slaves senden die erfassten Daten gesammelt an einen Master.&amp;nbsp;&lt;BR /&gt;Leider ist die Visualisierung der Software nicht gut genug weshalb wir nun mit qlik nachhelfen müssen.&amp;nbsp;&lt;BR /&gt;Falls Du Fragen zu dem Thema hast, gerne mit einer Nachricht melden.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Best regards.&amp;nbsp;&lt;BR /&gt;Karim&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 23:22:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-Productive-Runtime-of-Maschines/m-p/1879818#M72519</guid>
      <dc:creator>KarimBen</dc:creator>
      <dc:date>2022-01-11T23:22:01Z</dc:date>
    </item>
  </channel>
</rss>

