<?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 Count days for visit in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204443#M61348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;You just need to go through a couple more steps in order to clean up the data structure. The following should give what you are after:&lt;/P&gt;&lt;PRE&gt;Visits: LOAD * INLINE [ AdmitDateTime, DischargeDateTime, VisitID 1/1/2011, 1/1/2011, 1 1/1/2011, 1/2/2011, 2 1/2/2011, 1/2/2011, 3 1/2/2011, 1/3/2011, 4 1/2/2011, 1/4/2011, 5 1/2/2011, 1/5/2011, 6];Calendar:Load * INLINE [ DateNum, CalendarDate 1, 1/1/2011 2, 1/2/2011 3, 1/3/2011 4, 1/4/2011 5, 1/5/2011 6, 1/6/2011];LEFT JOIN (Calendar)INTERVALMATCH (CalendarDate)LOAD AdmitDateTime, DischargeDateTimeResident Visits;LEFT JOIN (Calendar)LOAD AdmitDateTime, DischargeDateTime, VisitIDResident Visits;DROP FIELD AdmitDateTime FROM Calendar;DROP FIELD DischargeDateTime FROM Calendar;&lt;/PRE&gt;&lt;P&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Apr 2011 22:58:14 GMT</pubDate>
    <dc:creator>stevedark</dc:creator>
    <dc:date>2011-04-07T22:58:14Z</dc:date>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204440#M61345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table with VisitID, AdmitDateTime, and DischargeDateTime. I need to count the number of patients in the hospital each day. Each record(VisitID) could have 1 or more days. For example:&lt;/P&gt;&lt;P&gt;A- VisitID = 1 The patient was admitted on 1/1/2011 and discharged on 1/1/2011 that would be a count of 1.&lt;/P&gt;&lt;P&gt;B- VisitID = 2 The patient was admitted on 1/1/2011 and discharged on 1/3/2011 that would be a count of 3.&lt;/P&gt;&lt;P&gt;I have been trying to get the load script to take each record and break it out into individual records for each day so the two examples above would look like this in a new table:&lt;/P&gt;&lt;P&gt;XID VisitID XDate&lt;BR /&gt;1 1 1/1/2011&lt;BR /&gt;2 2 1/1/2011&lt;BR /&gt;3 2 1/2/2011&lt;BR /&gt;4 2 1/3/2011&lt;/P&gt;&lt;P&gt;Below I have included what I have so far. I know there is a lot wrong with it but I hope maybe it might help explain what I need to do. Maybe I am way off and there is a better way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Visits:&lt;BR /&gt; LOAD * INLINE [&lt;BR /&gt; AdmitDateTime, DischargeDateTime, VisitID&lt;BR /&gt; 1/1/2011, 1/1/2011, 1&lt;BR /&gt; 1/1/2011, 1/2/2011, 2&lt;BR /&gt; 1/2/2011, 1/2/2011, 3&lt;BR /&gt; 1/2/2011, 1/3/2011, 4&lt;BR /&gt; 1/2/2011, 1/4/2011, 5&lt;BR /&gt; 1/2/2011, 1/5/2011, 6&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt; Visits AS XVisits,&lt;BR /&gt; Do While CalendarDate &amp;gt;= AdmitDateTime AND &amp;lt;= DischargeDateTime&lt;BR /&gt; CalendarDate = Xxxxxxxxxxxxxxxxx AS XDate&lt;BR /&gt; XID = Xxxxxxxxxxxxxxxxxxxxxxxxxxxx&lt;/P&gt;&lt;P&gt;Loop&lt;BR /&gt;&lt;BR /&gt;RESIDENT Visits&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;DROP TABLE Visits;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Apr 2011 20:01:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204440#M61345</guid>
      <dc:creator>dhborchardt</dc:creator>
      <dc:date>2011-04-07T20:01:54Z</dc:date>
    </item>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204441#M61346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;To get the table structure how you are describing I suggest you search for information on the IntervalMatch statement - I suspect you may find a posting on the community describing how to achieve exactly what you are after.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Apr 2011 20:19:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204441#M61346</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2011-04-07T20:19:30Z</dc:date>
    </item>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204442#M61347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Steve&lt;/P&gt;&lt;P&gt;I banged my head against the wall for a while but got it to work with the IntervalMatch. Even thought it gives me synthetic keys it comes up with the correct result. I am guessing I need a left join somewhere in there. Any Recommendations?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Visits:&lt;BR /&gt; LOAD * INLINE [&lt;BR /&gt; AdmitDateTime, DischargeDateTime, VisitID&lt;BR /&gt; 1/1/2011, 1/1/2011, 1&lt;BR /&gt; 1/1/2011, 1/2/2011, 2&lt;BR /&gt; 1/2/2011, 1/2/2011, 3&lt;BR /&gt; 1/2/2011, 1/3/2011, 4&lt;BR /&gt; 1/2/2011, 1/4/2011, 5&lt;BR /&gt; 1/2/2011, 1/5/2011, 6&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;Calendar:&lt;BR /&gt;Load * INLINE [&lt;BR /&gt; DateNum, CalendarDate&lt;BR /&gt; 1, 1/1/2011&lt;BR /&gt; 2, 1/2/2011&lt;BR /&gt; 3, 1/3/2011&lt;BR /&gt; 4, 1/4/2011&lt;BR /&gt; 5, 1/5/2011&lt;BR /&gt; 6, 1/6/2011&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;CountDays:&lt;BR /&gt;INTERVALMATCH (CalendarDate)&lt;BR /&gt;LOAD&lt;BR /&gt; AdmitDateTime,&lt;BR /&gt; DischargeDateTime&lt;BR /&gt;&lt;BR /&gt;Resident Visits&lt;BR /&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Apr 2011 22:31:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204442#M61347</guid>
      <dc:creator>dhborchardt</dc:creator>
      <dc:date>2011-04-07T22:31:52Z</dc:date>
    </item>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204443#M61348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;You just need to go through a couple more steps in order to clean up the data structure. The following should give what you are after:&lt;/P&gt;&lt;PRE&gt;Visits: LOAD * INLINE [ AdmitDateTime, DischargeDateTime, VisitID 1/1/2011, 1/1/2011, 1 1/1/2011, 1/2/2011, 2 1/2/2011, 1/2/2011, 3 1/2/2011, 1/3/2011, 4 1/2/2011, 1/4/2011, 5 1/2/2011, 1/5/2011, 6];Calendar:Load * INLINE [ DateNum, CalendarDate 1, 1/1/2011 2, 1/2/2011 3, 1/3/2011 4, 1/4/2011 5, 1/5/2011 6, 1/6/2011];LEFT JOIN (Calendar)INTERVALMATCH (CalendarDate)LOAD AdmitDateTime, DischargeDateTimeResident Visits;LEFT JOIN (Calendar)LOAD AdmitDateTime, DischargeDateTime, VisitIDResident Visits;DROP FIELD AdmitDateTime FROM Calendar;DROP FIELD DischargeDateTime FROM Calendar;&lt;/PRE&gt;&lt;P&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Apr 2011 22:58:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204443#M61348</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2011-04-07T22:58:14Z</dc:date>
    </item>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204444#M61349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;P&gt;That did the trick.&lt;/P&gt;&lt;P&gt;Usually by the time I get a new function to work I understand what is going on with it. In the case of IntervalMatch, I am still lost. I know how to use it in this case but I don't understand what is going on. How does it magically know I want to count the days? Could this be used somehow to count the hours within a day. Lets say someone was admitted the day before and discharged at noon today. That would be 12 hours on this day. Right now I do this sort of thing with a very long IF statement.&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 13:43:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204444#M61349</guid>
      <dc:creator>dhborchardt</dc:creator>
      <dc:date>2011-04-08T13:43:53Z</dc:date>
    </item>
    <item>
      <title>Count days for visit</title>
      <link>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204445#M61350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;You probably could use an interval match - but for every day you would obviously have 24 rows and would end up with a load script that took a while to run and lots of rows for QlikView to work on at display time.&lt;/P&gt;&lt;P&gt;What you could probably do is stamp on each daily record how many hours (or even minutes) of that day the patient was in for. The best way to achieve this may be a resident load from the table you already have, stamping 1 on whole days in (i.e. where the day is not the first or last day of stay) and a fraction where the day is the first, last or both. You can then just sum up that column to find cumulative days between dates.&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2011 21:46:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-days-for-visit/m-p/204445#M61350</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2011-04-08T21:46:22Z</dc:date>
    </item>
  </channel>
</rss>

