<?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: need help with previous () in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872542#M1003832</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for taking the time to help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that I missed something like that but all my attempts to create something just caused havoc. I will try this evening when said kids are sleeping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you much very both of you. I really appreciate it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 14 Jun 2015 06:49:37 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-06-14T06:49:37Z</dc:date>
    <item>
      <title>need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872538#M1003828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A friend set me an exercise and i think im on the right track but i have gotten stuck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The scenario is looking at patient admissions and readmission. Im stuck when it comes to looking at readmission. I dont seem to get previous correct, at least not the whole way. &lt;SPAN style="text-decoration: underline;"&gt;I wasnt to be able to choose a patient and then see if that patient is readmitted (and when).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VårdID = specific ID for each hospitalisation&lt;/P&gt;&lt;P&gt;PatientID = specific ID for each patient&lt;/P&gt;&lt;P&gt;Start = time of admission (timestamp)&lt;/P&gt;&lt;P&gt;Slut = time of discharge (timestamp)&lt;/P&gt;&lt;P&gt;Occupancy = how many days a patient has been at the hospital for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ps, DateID is then used in a master calendar. I can post that part as well if needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempVårdTid:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[nico återinläggning.xlsx]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is Blad1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;VårdTid:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Occupancy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TempDateID + Iterno() - 1 as DateID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; While TempDateID + IterNo() - 1 &amp;lt;= EndDateID;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID AS Occupancy,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Floor (Start) as TempDateID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(IsNull(Slut), Floor(Today()), Floor(Slut)) as EndDateID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Resident TempVårdTid;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempAdmission:&lt;/P&gt;&lt;P&gt;noConcatenate&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID AS Admission,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Floor(Start) as DateID&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previous (VårdID) as Next&lt;/P&gt;&lt;P&gt;Resident TempVårdTid;&lt;/P&gt;&lt;P&gt;//order by PatientID desc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Admission:&lt;/P&gt;&lt;P&gt;Concatenate (VårdTid)&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Admission,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; previous (Admission) as Next&lt;/P&gt;&lt;P&gt;Resident TempAdmission&lt;/P&gt;&lt;P&gt;order by PatientID, DateID&amp;nbsp; desc;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TempAdmission;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Discharge:&lt;/P&gt;&lt;P&gt;Concatenate (VårdTid)&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VårdID AS Discharge,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Slut,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Floor(Slut) as DateID&lt;/P&gt;&lt;P&gt;Resident TempVårdTid&lt;/P&gt;&lt;P&gt;Where not IsNull(Slut);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TempVårdTid;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: nicola cavallini Attached a file I have been practicing with, hopefully making what i need more clear.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 09:56:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872538#M1003828</guid>
      <dc:creator />
      <dc:date>2015-06-11T09:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872539#M1003829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that you misunderstand what previous does. Previous merely looks at the previous record of the source table. It can't look into any other tables. It also won't check if other fields from the previous record are different or the same as the current record. Those check are up to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to create a table with all the admissions sorted by patient and admission date. Then you can use the previous function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AdmissionDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(Previous(PatientID)=PatientID, 1, 0) as IsReadmission&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...other fields...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;RESIDENT&lt;EM&gt; ...some_table....&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;ORDER BY PatientID, AdmissionDate&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 12:43:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872539#M1003829</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-06-12T12:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872540#M1003830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are missing some way of checking if the Previous(Admission) is actually related to the same patient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;P&gt;If(Previous(PatientID)=Patient, Previous(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Admission&lt;/SPAN&gt;)) as Next&lt;/P&gt;&lt;P&gt;instead of&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;previous (Admission) as Next&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 13:26:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872540#M1003830</guid>
      <dc:creator>kuba_michalik</dc:creator>
      <dc:date>2015-06-12T13:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872541#M1003831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. I try to look at another table, or at least not purposely. The issue is that AdmissionsTImes (Start) arent unique, thats why i tried to use "vårdID".&amp;nbsp; Did you have an opportunity to look at the excel file I attached? Isnt that table sorted like you explain?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will look at your example in dept this evening when the kids are sleeping and dont want to serve me imaginary coffe &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for taking this long to reply. I have been stomach ill for the last 3 days. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jun 2015 06:47:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872541#M1003831</guid>
      <dc:creator />
      <dc:date>2015-06-14T06:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872542#M1003832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for taking the time to help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought that I missed something like that but all my attempts to create something just caused havoc. I will try this evening when said kids are sleeping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you much very both of you. I really appreciate it. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Jun 2015 06:49:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872542#M1003832</guid>
      <dc:creator />
      <dc:date>2015-06-14T06:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872543#M1003833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jakub, that answered my question perfectly. I only had to make sure to sort by PatientID and Start. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately that was only part of what I needed. Now I need to figure out a few more things, e.g. how to calculate how far (in days) in the future ReAdission (Next) is located takes place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestion ??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2015 19:37:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872543#M1003833</guid>
      <dc:creator />
      <dc:date>2015-06-17T19:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: need help with previous ()</title>
      <link>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872544#M1003835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Floor(Next) - Floor(Start)&lt;/P&gt;&lt;P&gt;should give you a difference in days between two dates. Just make sure to use it after the [Next] field is actually created (using preceding load or in a subsequent load resident).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2015 12:29:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/need-help-with-previous/m-p/872544#M1003835</guid>
      <dc:creator>kuba_michalik</dc:creator>
      <dc:date>2015-06-18T12:29:40Z</dc:date>
    </item>
  </channel>
</rss>

