<?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: Execute Set Analysis stored in a table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304745#M1187639</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the explaination on the order of execution.&amp;nbsp; Now I understand why I'm getting those results in my chart.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if the pick idea will work for what I'm doing, but I will keep that in mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Aug 2011 12:58:45 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-08-29T12:58:45Z</dc:date>
    <item>
      <title>Execute Set Analysis stored in a table</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304743#M1187637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greetings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a series of complex set analys that need to be executed based on certain values in a table.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;KeyValue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;SetAnalysis&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;MU1&lt;/TD&gt;&lt;TD&gt;&amp;lt;DenomMeasureID={"MU1"}, OnsetDate={"&amp;gt;=$(vPeriodStart)&amp;lt;=$(vPeriodEnd)"}&amp;gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;MU2&lt;/TD&gt;&lt;TD&gt;&amp;lt;DenomMeasureID={"MU2"}, OnsetDate={"&amp;gt;=$(vPeriodStart)&amp;lt;=$(=DATE('$(vPeriodEnd)' -4))"}, DenomType={"REQUESTEDPHI"}&amp;gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;MU3&lt;/TD&gt;&lt;TD&gt;&amp;lt;NPCDate={"&amp;gt;=$(vDenomStart)&amp;lt;=$(vPeriodEnd)"}, NPCDenomType={"Encounter"}, NPCDenomValue={$(vMU3EMCodes)} &amp;gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can dump the SetAnalysis value in a chart, but if I tried to do the following code, it gives me null or the entire set of IDs.&amp;nbsp; For example, the Dimension in the chart is KeyValue, and an Expression in the chart is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT { $(SetAnalysis) }&amp;nbsp; PatientID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I replace the Expression with this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT { &amp;lt;DenomMeasureID={"MU1"}, OnsetDate={"&amp;gt;=$(vPeriodStart)&amp;lt;=$(vPeriodEnd)"}&amp;gt; }&amp;nbsp; PatientID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works fine (well... it give the same value for all rows, which is not what I'm trying to accomplish).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried a number of variations:&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT { $(=SetAnalysis) }&amp;nbsp; PatientID)&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT { SetAnalysis }&amp;nbsp; PatientID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And nothing gives me what I want.&amp;nbsp; What am I doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 19:50:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304743#M1187637</guid>
      <dc:creator />
      <dc:date>2011-08-26T19:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: Execute Set Analysis stored in a table</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304744#M1187638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dollar sign expansion is done up front, outside of the context of your chart dimensions.&amp;nbsp; At that time, unless you've selected a single KeyValue, SetAnalysis has multiple values, and therefore returns null.&amp;nbsp; So then you probably just count the distinct PatientIDs, ignoring the set you wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you avoid the dollar sign expansion by just sticking the field in there directly, it &lt;EM&gt;will&lt;/EM&gt; have a unique value for SetAnalysis.&amp;nbsp; However, at that point, it will be a string, not something actually inserted into the code to be evaluated.&amp;nbsp; In other words, I think it would be the equivalent of this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;COUNT( DISTINCT {&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;lt;DenomMeasureID={"MU1"}, OnsetDate={"&amp;gt;=$(vPeriodStart)&amp;lt;=$(vPeriodEnd)"}&amp;gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/SPAN&gt;}&amp;nbsp; PatientID)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the single quotes make this a completely invalid expression, and so I would expect it to return null.&amp;nbsp; You just can't use field values this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The evaluate() function would be perfect, except that it's explicitly disallowed in expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best way I've found to get around these limitations (and I'm not saying it's a good way) is to generate a pick() expression that can then choose the correct expression to apply.&amp;nbsp; See attached example.&amp;nbsp; Script for the expression part and variable generation below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Metric:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD recno() as MetricSequence,* INLINE [&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Metric, Expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Count, count(Amount)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Max, max(Amount)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Total, sum(Amount)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Metrics:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD concat(Expression,',',MetricSequence) as AllExpressions&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Metric;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LET vMetrics = 'pick(MetricSequence,' &amp;amp; peek('AllExpressions') &amp;amp; ')';&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DROP TABLE Metrics;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 20:11:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304744#M1187638</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-26T20:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Execute Set Analysis stored in a table</title>
      <link>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304745#M1187639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the explaination on the order of execution.&amp;nbsp; Now I understand why I'm getting those results in my chart.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if the pick idea will work for what I'm doing, but I will keep that in mind.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 12:58:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Execute-Set-Analysis-stored-in-a-table/m-p/304745#M1187639</guid>
      <dc:creator />
      <dc:date>2011-08-29T12:58:45Z</dc:date>
    </item>
  </channel>
</rss>

