<?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: Load data from table A based on field in table B in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2028795#M84765</link>
    <description>&lt;P&gt;thanks, quite easy with the join.&lt;/P&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Andreas&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 12:44:34 GMT</pubDate>
    <dc:creator>ARe</dc:creator>
    <dc:date>2023-01-23T12:44:34Z</dc:date>
    <item>
      <title>Load data from table A based on field in table B</title>
      <link>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2026237#M84607</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm somehow stuck. I got some patient data where a patient is identified by a patientfrid and for each patient there may be multiple cases (casefrid). one row per case.&lt;/P&gt;
&lt;P&gt;Also there is a table with variables (gender, weight, ...) with some value and the information of the patient.&lt;/P&gt;
&lt;P&gt;For each case I need to find the latest gender, weight, .... with respect to the enddate of the case (meaning last weight before case end).&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;[cases]:
load * inline
[casefrid, patientfrid, CaseStart, CaseEnd
cm1, pf1, 44930, 44950
];

[Variablen_tmp]:
load * inline
[patientfrid, valuetime, value, vvfrid, name
pf1, 44940, 80, vvfrid1, weight

pf1, 44990, 90, vvfrid1, weight
pf2, 44945, female, vvfrid2, gender
pf3, 44960, male, vvfrid3, gender
];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;finding the latest weight is in principial quite easy using firstsortedvalue:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;[casesNEW]:
load * resident cases;
left join load patientfrid,
FirstSortedValue(DISTINCT [value], -[valuetime]) AS 'Weight'
Resident [Variablen_tmp]
Where [name] = 'weight'
Group By [patientfrid];&lt;/LI-CODE&gt;
&lt;P&gt;but that gives me the latest weight for the patient (which is 90). I'm looking for the last weight before case end (which would be 80).&lt;/P&gt;
&lt;P&gt;I would need so sort of "where valuetime &amp;lt;= caseend" but that is not possible (message: field not found).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I _think_ intervalmatch could help but I'm not sure how.&lt;/P&gt;
&lt;P&gt;When I add&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;left join
intervalmatch(valuetime,patientfrid)
load distinct PeriopStart, PeriopEnd,patientfrid resident cases;&lt;/LI-CODE&gt;
&lt;P&gt;to the [Variablen_tmp] table then I'm still missing the casefrid which I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any suggestions?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;BR Andreas&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 13:28:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2026237#M84607</guid>
      <dc:creator>ARe</dc:creator>
      <dc:date>2023-01-17T13:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Load data from table A based on field in table B</title>
      <link>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2028448#M84736</link>
      <description>&lt;P&gt;Would something like the following work?&lt;/P&gt;
&lt;P&gt;[cases]:&lt;BR /&gt;load * inline&lt;BR /&gt;[casefrid, patientfrid, CaseStart, CaseEnd&lt;BR /&gt;cm1, pf1, 44930, 44950&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;join&lt;/P&gt;
&lt;P&gt;[Variablen_tmp]:&lt;BR /&gt;load * inline&lt;BR /&gt;[patientfrid, valuetime, value, vvfrid, name&lt;BR /&gt;pf1, 44940, 80, vvfrid1, weight&lt;/P&gt;
&lt;P&gt;pf1, 44990, 90, vvfrid1, weight&lt;BR /&gt;pf2, 44945, female, vvfrid2, gender&lt;BR /&gt;pf3, 44960, male, vvfrid3, gender&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;[casesNEW]:&lt;BR /&gt;load&lt;BR /&gt;casefrid,&lt;BR /&gt;patientfrid,&lt;BR /&gt;FirstSortedValue(DISTINCT [value], -[valuetime]) AS "Weight"&lt;BR /&gt;Resident [cases]&lt;BR /&gt;Where [name] = 'weight'&lt;BR /&gt;and valuetime &amp;lt;= CaseEnd&lt;BR /&gt;Group By [casefrid], [patientfrid];&lt;/P&gt;
&lt;P&gt;drop table [cases];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the following data from this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KGalloway_0-1674250373148.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/98541i1EC519D524021442/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KGalloway_0-1674250373148.png" alt="KGalloway_0-1674250373148.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 21:33:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2028448#M84736</guid>
      <dc:creator>KGalloway</dc:creator>
      <dc:date>2023-01-20T21:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Load data from table A based on field in table B</title>
      <link>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2028795#M84765</link>
      <description>&lt;P&gt;thanks, quite easy with the join.&lt;/P&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Andreas&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 12:44:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-data-from-table-A-based-on-field-in-table-B/m-p/2028795#M84765</guid>
      <dc:creator>ARe</dc:creator>
      <dc:date>2023-01-23T12:44:34Z</dc:date>
    </item>
  </channel>
</rss>

