<?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: Set analysis on two levels in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558640#M40689</link>
    <description>&lt;P&gt;i'd suggest you create/calculate a field in your datamodel "_latest_test_result"&amp;nbsp;&lt;/P&gt;&lt;P&gt;and use it in your set analysis instead. (indeed, expressions are evaluated once per chart - not per dimension)&lt;/P&gt;&lt;P&gt;(&amp;lt;_latest_test_result={1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;Observations:&amp;nbsp;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;latestTestResults:&amp;nbsp;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;PatientID,&lt;/P&gt;&lt;P&gt;max(&lt;SPAN&gt;ObservationDate&lt;/SPAN&gt;)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;as latestDate,&lt;/P&gt;&lt;P&gt;firstsortedvalue(ObservationID,&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;-&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;ObservationDate&lt;/SPAN&gt;)&amp;nbsp; &amp;nbsp;as ObservationID&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; as&amp;nbsp;_latest_test_result&lt;/P&gt;&lt;P&gt;resident Observations&lt;/P&gt;&lt;P&gt;group by PatientID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;drop field&amp;nbsp;PatientID from&amp;nbsp;latestTestResults;&amp;nbsp; OR left join the entire latestTestResultTable?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2019 20:29:41 GMT</pubDate>
    <dc:creator>mikaelsc</dc:creator>
    <dc:date>2019-03-19T20:29:41Z</dc:date>
    <item>
      <title>Set analysis on two levels</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558608#M40687</link>
      <description>&lt;P&gt;I have hit a wall with trying to solve this... The goal: Create a KPI that counts the number of patients whose most recent blood test had a specific result.&lt;/P&gt;&lt;P&gt;My data has fields named ObservationDate, [HbA1C Group], Patient.&lt;/P&gt;&lt;P&gt;I need to find each patient's most recent ObservationDate, then determine if the value of [HbA1C Group] on that date was '5.7 to 6.4'. If yes, then include the patient in the count.&lt;/P&gt;&lt;P&gt;This doesn't work because it gets the max date for the entire population, not each patient:&lt;/P&gt;&lt;PRE&gt;=Count({&amp;lt;[HbA1C Group]={'5.7 to 6.4'}, ObservationDate={"$(=max(ObservationDate))"}&amp;gt;} distinct Patient))&lt;/PRE&gt;&lt;P&gt;I've tried enclosing it in Aggr in various ways, with and without an If() function. No luck.&lt;/P&gt;&lt;P&gt;Thanks for any advice.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 18:41:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558608#M40687</guid>
      <dc:creator>Lauri</dc:creator>
      <dc:date>2019-03-19T18:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis on two levels</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558640#M40689</link>
      <description>&lt;P&gt;i'd suggest you create/calculate a field in your datamodel "_latest_test_result"&amp;nbsp;&lt;/P&gt;&lt;P&gt;and use it in your set analysis instead. (indeed, expressions are evaluated once per chart - not per dimension)&lt;/P&gt;&lt;P&gt;(&amp;lt;_latest_test_result={1}&amp;gt;...)&lt;/P&gt;&lt;P&gt;Observations:&amp;nbsp;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;latestTestResults:&amp;nbsp;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;PatientID,&lt;/P&gt;&lt;P&gt;max(&lt;SPAN&gt;ObservationDate&lt;/SPAN&gt;)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;as latestDate,&lt;/P&gt;&lt;P&gt;firstsortedvalue(ObservationID,&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;-&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;ObservationDate&lt;/SPAN&gt;)&amp;nbsp; &amp;nbsp;as ObservationID&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; as&amp;nbsp;_latest_test_result&lt;/P&gt;&lt;P&gt;resident Observations&lt;/P&gt;&lt;P&gt;group by PatientID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;drop field&amp;nbsp;PatientID from&amp;nbsp;latestTestResults;&amp;nbsp; OR left join the entire latestTestResultTable?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 20:29:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558640#M40689</guid>
      <dc:creator>mikaelsc</dc:creator>
      <dc:date>2019-03-19T20:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis on two levels</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558654#M40690</link>
      <description>&lt;P&gt;Thanks! That makes good sense and works in my situation. How would you handle it if you wanted it to be dynamic - so the user could choose the year within which the latest ObservationDate had to be?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 21:20:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1558654#M40690</guid>
      <dc:creator>Lauri</dc:creator>
      <dc:date>2019-03-19T21:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis on two levels</title>
      <link>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1568841#M41490</link>
      <description>&lt;P&gt;In case others come looking, here is what I ended up doing for the dynamic situation. The earlier solution was good for counting patients based on their most recent result (ever!). But I needed to have a different set of results for each of many time periods.&lt;/P&gt;&lt;P&gt;My load script creates an As-Of table containing every month. I created a bar chart with AsOfMonth as the dimension. The measure is this:&lt;/P&gt;&lt;PRE&gt;Count({&amp;lt;IsRolling12={1}, AsOfMonth=, [Diabetic Ever]={'Yes'}, 
 Patient={"=FirstSortedValue({&amp;lt;ObservationName={'HEMOGLOBIN A1C'}&amp;gt;} 
ObservationValue, -ObservationDate)&amp;gt;9"}&amp;gt;} distinct Patient)&lt;/PRE&gt;&lt;P&gt;The valuable part here is the FirstSortedValue function:&lt;/P&gt;&lt;PRE&gt;Patient={"=FirstSortedValue({&amp;lt;ObservationName={'HEMOGLOBIN A1C'}&amp;gt;} 
ObservationValue, -ObservationDate)&amp;gt;9"}&lt;/PRE&gt;&lt;P&gt;It returns members of the Patient dimension whose most recent ObservationValue&amp;nbsp; is greater than 9. The other set analysis statements limit it to a rolling 12 months, among patients diagnosed with diabetes.&lt;/P&gt;&lt;P&gt;So no need for Aggr.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2019 15:12:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Set-analysis-on-two-levels/m-p/1568841#M41490</guid>
      <dc:creator>Lauri</dc:creator>
      <dc:date>2019-04-12T15:12:19Z</dc:date>
    </item>
  </channel>
</rss>

