<?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: Calculations within a daterange - help! in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258369#M397289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tamil, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just did. Just hade to put some finishing touches on the reply. Hope it helps someone else struggling with this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Nov 2016 06:41:22 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-11-25T06:41:22Z</dc:date>
    <item>
      <title>Calculations within a daterange - help!</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258366#M397286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Community and thank you for all helpful your posts! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out the best way of performing a certain calculation and I would really appreciate your input on this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try to explain what I'm after using some sample data. Here goes. &lt;/P&gt;&lt;P&gt;I have patient data, with patient ID (patID) and AppointmentDate (YYYY-MM-DD), coupled to a specific Clinic:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="PatientData.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/143998_PatientData.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;I also have invoice data, with InvoiceNr, InvoiceDate &lt;SPAN style="font-size: 13.3333px;"&gt;(YYYY-MM-DD)&lt;/SPAN&gt; also coupled to a Clinic:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Invoice data.png" class="jive-image image-2" src="/legacyfs/online/144000_Invoice data.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's what I'd like to do: &lt;/P&gt;&lt;P&gt;I want to count eg. the number of PatIDs that have visited the clinic during a specific period of time. That period is defined as the period between invoices, plz consult the color-coded picture below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Coupling.png" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/144002_Coupling.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;So, for Invoice Nr 3003, I want to see all patients between 2016-02-08 and before 2016-03-01. In this example only patient with ID 105. &lt;/P&gt;&lt;P&gt;Resulting in: &lt;/P&gt;&lt;P&gt;&lt;IMG alt="Result.png" class="image-4 jive-image" src="https://community.qlik.com/legacyfs/online/144003_Result.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would you accomplish this? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nathalie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2016 09:04:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258366#M397286</guid>
      <dc:creator />
      <dc:date>2016-11-16T09:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations within a daterange - help!</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258367#M397287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With some exemplary help from &lt;A href="https://community.qlik.com/qlik-users/68042"&gt;liivirimling&lt;/A&gt;, I got this to work!&lt;/P&gt;&lt;P&gt;So I thought I'd share the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to use IntervalMatch, so I need to have a start and a stop date to create the interval. The InvoiceStop is the day before the Invoice Date (My sourcedata gives invoice date as a TimeStamp, thus the use of Floor() and Date() function):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[InvoiceData]:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD DISTINCT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Floor(&lt;SPAN style="font-size: 13.3333px;"&gt;invoicedate&lt;/SPAN&gt;), 'YYYY-MM-DD') as InvoiceDate,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Floor(&lt;SPAN style="font-size: 13.3333px;"&gt;invoicedate&lt;/SPAN&gt;)-1, 'YYYY-MM-DD') as InvoiceStop,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "invoice number" as InvoiceNr,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clinic as Clinic&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;That took care of the Stop, now for the Start: &lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;Left Join (InvoiceData)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD DISTINCT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Clinic,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceNr,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(previous(Clinic)=Clinic, Date(Previous(InvoiceStop+1)), yearstart(InvoiceDate)) as InvoiceStart&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident InvoiceDate&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;order by Clinic, InvoiceDate;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I sort my data by Clinic and then by InvoiceDate and then use the Previous() function to fetch the date of the previous invoice as InvoiceStart, but only for as long as the Clinic is the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now we have a Start and a Stop. We proceed to IntervalMatch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IntervalMatch(AppointmentDate, Clinic)&amp;nbsp; &lt;/STRONG&gt;&lt;EM&gt;//States which field to match, states Key Field&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;Left join (PatientData)&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;EM&gt;//States which table to join the results&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceStart,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceStop,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceNr&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident [InvoiceData];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IntervalMatch now checks patient appointment date with the starts and stops.&lt;/P&gt;&lt;P&gt;Lastly. I joined the InvoiceNr to the PatientData table and drop the unnecessary fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Left join (&lt;SPAN style="font-size: 10pt;"&gt;PatientData&lt;/SPAN&gt;) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; InvoiceStart, &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceStop,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Clinic,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; InvoiceNr&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident [InvoiceData];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Drop fields InvoiceStop, InvoiceStart, Clinic&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM &lt;SPAN style="font-size: 10pt;"&gt;PatientData&lt;/SPAN&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2016 06:20:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258367#M397287</guid>
      <dc:creator />
      <dc:date>2016-11-25T06:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations within a daterange - help!</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258368#M397288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great Nathalie. Kindly close this thread by marking your own response as correct answer. Have a nice day.&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2016 06:37:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258368#M397288</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2016-11-25T06:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations within a daterange - help!</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258369#M397289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tamil, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just did. Just hade to put some finishing touches on the reply. Hope it helps someone else struggling with this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice day! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2016 06:41:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-within-a-daterange-help/m-p/1258369#M397289</guid>
      <dc:creator />
      <dc:date>2016-11-25T06:41:22Z</dc:date>
    </item>
  </channel>
</rss>

