<?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 Find a list base on date in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Find-a-list-base-on-date/m-p/1939193#M77417</link>
    <description>&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;I have many facilities where patients can go for treatment.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;The patients have a unique Id (patients_id). &amp;nbsp;I want to assign a patient to the last facility they want to. If Patient&amp;nbsp;&lt;STRONG&gt;001&lt;/STRONG&gt;&amp;nbsp;goes to facility&amp;nbsp;&lt;STRONG&gt;A&lt;/STRONG&gt;&amp;nbsp;on&amp;nbsp;05/06/2021&amp;nbsp;and then that same patient goes to facility&amp;nbsp;&lt;STRONG&gt;B&lt;/STRONG&gt;&amp;nbsp;on&amp;nbsp;05/07/2021. The patient will be in facility&amp;nbsp;&lt;STRONG&gt;B&lt;/STRONG&gt;&amp;nbsp;because he wants here last.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;When I click on the name of the facility, I want a count of all the patients that facility.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;=Count({&amp;lt;&lt;/P&gt;
&lt;P&gt;patient_id={"=Age &amp;gt;=18"}&lt;/P&gt;
&lt;P&gt;,visit_date={"$(=Date(max(visit_date)))"}&lt;/P&gt;
&lt;P&gt;&amp;gt;}DISTINCT patient_id)&lt;/P&gt;
&lt;P&gt;I was help with the above but I think max only returns one date which is the last one in the list&lt;/P&gt;
&lt;P&gt;I keep getting zero when I should get thousands&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2022 20:20:47 GMT</pubDate>
    <dc:creator>earlcool</dc:creator>
    <dc:date>2022-06-02T20:20:47Z</dc:date>
    <item>
      <title>Find a list base on date</title>
      <link>https://community.qlik.com/t5/App-Development/Find-a-list-base-on-date/m-p/1939193#M77417</link>
      <description>&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;I have many facilities where patients can go for treatment.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;The patients have a unique Id (patients_id). &amp;nbsp;I want to assign a patient to the last facility they want to. If Patient&amp;nbsp;&lt;STRONG&gt;001&lt;/STRONG&gt;&amp;nbsp;goes to facility&amp;nbsp;&lt;STRONG&gt;A&lt;/STRONG&gt;&amp;nbsp;on&amp;nbsp;05/06/2021&amp;nbsp;and then that same patient goes to facility&amp;nbsp;&lt;STRONG&gt;B&lt;/STRONG&gt;&amp;nbsp;on&amp;nbsp;05/07/2021. The patient will be in facility&amp;nbsp;&lt;STRONG&gt;B&lt;/STRONG&gt;&amp;nbsp;because he wants here last.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-weight: 400;"&gt;&lt;SPAN&gt;When I click on the name of the facility, I want a count of all the patients that facility.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;=Count({&amp;lt;&lt;/P&gt;
&lt;P&gt;patient_id={"=Age &amp;gt;=18"}&lt;/P&gt;
&lt;P&gt;,visit_date={"$(=Date(max(visit_date)))"}&lt;/P&gt;
&lt;P&gt;&amp;gt;}DISTINCT patient_id)&lt;/P&gt;
&lt;P&gt;I was help with the above but I think max only returns one date which is the last one in the list&lt;/P&gt;
&lt;P&gt;I keep getting zero when I should get thousands&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 20:20:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-a-list-base-on-date/m-p/1939193#M77417</guid>
      <dc:creator>earlcool</dc:creator>
      <dc:date>2022-06-02T20:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find a list base on date</title>
      <link>https://community.qlik.com/t5/App-Development/Find-a-list-base-on-date/m-p/1939704#M77465</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/173965"&gt;@earlcool&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a couple of issues in your statement, the first is the selection on&amp;nbsp;&lt;STRONG&gt;patient_id&lt;/STRONG&gt;. You need do the set based on&amp;nbsp;&lt;STRONG&gt;Age&lt;/STRONG&gt; rather than&amp;nbsp;&lt;STRONG&gt;patient_id&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;=Count({&amp;lt;Age*={"&amp;gt;=18"},visit_date={"$(=Date(max(visit_date)))"}&amp;gt;}DISTINCT patient_id)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The other problem is that the &lt;STRONG&gt;max(visit_date)&lt;/STRONG&gt; is looking at the latest date for any patient, not the specific patient being counted.&lt;/P&gt;
&lt;P&gt;Should the latest facility for a patient be based on current selections?&lt;/P&gt;
&lt;P&gt;If not I would suggest working out the latest record and facility for the patient in the load:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Patients:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;patient_id,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;visit_date,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;patient_id &amp;amp; date(visit_date, 'YYYYMMDD') as patientvisitkey,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;facility,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;... other patient detail fields ...&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;FROM ... ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;tmpMaxKey:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;maxstring(patientvisitkey) as MaxKey&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;RESIDENT&amp;nbsp;Patients&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GROUP BY patient_id;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;LatestFacility:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;patient_id,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;visit_date as latest_visit,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;facility as latest_facility&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;RESIDENT Patients&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;WHERE EXISTS (MaxKey,&amp;nbsp;patientvisitkey);&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;DROP TABLE&amp;nbsp;tmpMaxKey;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Once you have that new table with latest_facility and latest_visit you should be in a better place. You should probably make an&amp;nbsp;&lt;STRONG&gt;Is18&lt;/STRONG&gt; field in the load also, with a 0/1 value, to make that selection more efficient in the front end also.&lt;/P&gt;
&lt;P&gt;Hope that helps,&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 09:16:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Find-a-list-base-on-date/m-p/1939704#M77465</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2022-06-05T09:16:18Z</dc:date>
    </item>
  </channel>
</rss>

