<?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: Calculating the days between two dates in the same table but different 'rows' in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519232#M193933</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you!!&lt;/P&gt;&lt;P&gt;After i set all my filters in the listboxes i get the correct result!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just added one more thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;If(previous(BatchID)=BatchID and previous(PartID)=PartID and previous(ProcessStepID)=(ProcessStepID-1), DateCreated-previous(DateDelivered)) as WaitingTime&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Aug 2013 13:18:01 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-08-22T13:18:01Z</dc:date>
    <item>
      <title>Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519228#M193929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello QlikCommunity,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have already found solutions for a lot of problems i had here but now i'm stuck and hope you can help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm trying to do is subtract two dates and create a new field with the result.&lt;/P&gt;&lt;P&gt;e.g. DateCreated - DateDelivered = WaitingTime&lt;/P&gt;&lt;P&gt;So far this is nothing special and could easily be solved in the LOAD script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is "DateDelivered" has to come from a different DataSet (Row) in the same Table.&lt;/P&gt;&lt;P&gt;Please see this example for better understanding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;PartID&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;ProcessStepID&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;ProcessStep&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;BatchID&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG style="color: #ffffff; text-align: center;"&gt;DateCreated&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;DateDelivered&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;WaitingTime&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;01.01.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;17.01.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20.02.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;22.02.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;C&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;03.03.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;06.03.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;D&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;07.03.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10.03.2012&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WaitingTime&lt;/STRONG&gt; should be calculated by taking "&lt;STRONG&gt;DateDelivered&lt;/STRONG&gt;" of the current DataSet (e.g. PartID = 1; BatchID = 11; ProcessStepID = &lt;STRONG&gt;2&lt;/STRONG&gt;) and &lt;STRONG&gt;subtract&lt;/STRONG&gt; it from "&lt;STRONG&gt;DateCreated&lt;/STRONG&gt;" of the &lt;STRONG&gt;next&lt;/STRONG&gt; DataSet (e.g. PartID = 1; BatchID = 11; ProcessStepID = &lt;STRONG&gt;3&lt;/STRONG&gt;) in the same table.&lt;/P&gt;&lt;P&gt;I want to get the waiting/idle time between one finished step until the beginning of the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WaitingTime = DateCreated(ProcessStepIP=&lt;STRONG&gt;3&lt;/STRONG&gt;) - DateDelivered (ProcessStepID=&lt;STRONG&gt;2&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm really frustated as i have tried to find a solution for about 2 days now. I'm pretty new to QV and am really hoping for you guys to help me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 12:43:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519228#M193929</guid>
      <dc:creator />
      <dc:date>2013-08-22T12:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519229#M193930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;If(previous(BatchID)=BatchID and previous(PartID)=PartID, DateCreated-previous(DateDelivered)) as WaitingTime&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;from ...somewhere...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on your source data you may need to use the date# function on the dates to create numeric dates that can be subtracted from each other.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 12:50:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519229#M193930</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-08-22T12:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519230#M193931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RESULT:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PartID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStepID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStep,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BatchID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateCreated,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateDelivered,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp; if(peek(PartID) = PartID, DateCreated-peek(DateDelivered)) as WaitingTime&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;RESIDENT TABLE&lt;/P&gt;&lt;P&gt;ORDER BY PartID, ProcessStepID;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TABLE;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming you alread loaded TABLE with above fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 12:54:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519230#M193931</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-08-22T12:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519231#M193932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That didn't work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I should also mention that the Data is not sorted like in my example. I need to find the Row with the same BatchID and the same PartID but with the ProcessStepID of a previous ProcessStep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your example did calculate something but not in the correct way &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PartID appears numberous times but with a different BatchID etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 13:15:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519231#M193932</guid>
      <dc:creator />
      <dc:date>2013-08-22T13:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519232#M193933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you!!&lt;/P&gt;&lt;P&gt;After i set all my filters in the listboxes i get the correct result!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just added one more thing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;If(previous(BatchID)=BatchID and previous(PartID)=PartID and previous(ProcessStepID)=(ProcessStepID-1), DateCreated-previous(DateDelivered)) as WaitingTime&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 13:18:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519232#M193933</guid>
      <dc:creator />
      <dc:date>2013-08-22T13:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Calculating the days between two dates in the same table but different 'rows'</title>
      <link>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519233#M193934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can first load your data and then use a resident load to sort it and calculate the waiting time:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PartID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStepID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStep,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BatchID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateCreated,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateDelivered&lt;/P&gt;&lt;P&gt;FROM &lt;EM&gt;yoursourcehere&lt;/EM&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PartID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStepID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProcessStep,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BatchID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateCreated,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateDelivered&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(previous(BatchID)=BatchID and previous(PartID)=PartID, DateCreated-previous(DateDelivered)) as WaitingTime&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Temp&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;order by PartID, BatchID,ProcessStepID&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Drop table Temp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 13:49:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculating-the-days-between-two-dates-in-the-same-table-but/m-p/519233#M193934</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-08-22T13:49:55Z</dc:date>
    </item>
  </channel>
</rss>

