<?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 Set analysis returns unexpected results in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240237#M90783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, I need your help on this interesting case. I've got this data set :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;COLGROUP&gt;&lt;COL span="3" style="width: 60pt;" width="80" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 60pt;" width="80"&gt;Y&lt;STRONG&gt;ear&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2009&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/12/2009&lt;/TD&gt;&lt;TD align="right"&gt;912&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/06/2010&lt;/TD&gt;&lt;TD align="right"&gt;1006&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/09/2010&lt;/TD&gt;&lt;TD align="right"&gt;1009&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/01/2011&lt;/TD&gt;&lt;TD align="right"&gt;1101&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;28/02/2011&lt;/TD&gt;&lt;TD align="right"&gt;1102&lt;/TD&gt;&lt;/TR&gt;&lt;!--[endif]--&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I would like to get into a pivot chart , the year, the max date founded for each year and the value related to this max date, whatever the selection. It will look like :&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;COLGROUP&gt;&lt;COL span="3" style="width: 60pt;" width="80" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 60pt;" width="80"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Max({1}Date)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Expression&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2009&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/12/2009&lt;/TD&gt;&lt;TD align="right"&gt;912&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/09/2010&lt;/TD&gt;&lt;TD align="right"&gt;1009&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;28/02/2011&lt;/TD&gt;&lt;TD align="right"&gt;&lt;P&gt;1102&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I encounters some issues to resolve the Expression . I tried :&lt;/P&gt;&lt;P&gt;sum( {1&amp;lt;Date={'$(=Date(Max(Date)))'}&amp;gt;} Amount)&lt;/P&gt;&lt;P&gt;it returns the right value for year 2011 but 0 for previous years. What is missing in this set analysis to obtain the desired results or another way to solve the problem without getting back bo the script?&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Mar 2011 21:44:31 GMT</pubDate>
    <dc:creator>agilos_mla</dc:creator>
    <dc:date>2011-03-04T21:44:31Z</dc:date>
    <item>
      <title>Set analysis returns unexpected results</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240237#M90783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, I need your help on this interesting case. I've got this data set :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;COLGROUP&gt;&lt;COL span="3" style="width: 60pt;" width="80" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 60pt;" width="80"&gt;Y&lt;STRONG&gt;ear&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2009&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/12/2009&lt;/TD&gt;&lt;TD align="right"&gt;912&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/06/2010&lt;/TD&gt;&lt;TD align="right"&gt;1006&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/09/2010&lt;/TD&gt;&lt;TD align="right"&gt;1009&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/01/2011&lt;/TD&gt;&lt;TD align="right"&gt;1101&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;28/02/2011&lt;/TD&gt;&lt;TD align="right"&gt;1102&lt;/TD&gt;&lt;/TR&gt;&lt;!--[endif]--&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I would like to get into a pivot chart , the year, the max date founded for each year and the value related to this max date, whatever the selection. It will look like :&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; table-layout: fixed; width: 180pt;" width="240"&gt;&lt;COLGROUP&gt;&lt;COL span="3" style="width: 60pt;" width="80" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD class="xl65" height="20" style="height: 15.0pt; width: 60pt;" width="80"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Max({1}Date)&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl65" style="width: 60pt;" width="80"&gt;&lt;STRONG&gt;Expression&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2009&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;31/12/2009&lt;/TD&gt;&lt;TD align="right"&gt;912&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2010&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;30/09/2010&lt;/TD&gt;&lt;TD align="right"&gt;1009&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="20" style="height: 15.0pt;"&gt;&lt;TD align="right" height="20" style="height: 15.0pt;"&gt;2011&lt;/TD&gt;&lt;TD align="right" class="xl66"&gt;28/02/2011&lt;/TD&gt;&lt;TD align="right"&gt;&lt;P&gt;1102&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I encounters some issues to resolve the Expression . I tried :&lt;/P&gt;&lt;P&gt;sum( {1&amp;lt;Date={'$(=Date(Max(Date)))'}&amp;gt;} Amount)&lt;/P&gt;&lt;P&gt;it returns the right value for year 2011 but 0 for previous years. What is missing in this set analysis to obtain the desired results or another way to solve the problem without getting back bo the script?&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 21:44:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240237#M90783</guid>
      <dc:creator>agilos_mla</dc:creator>
      <dc:date>2011-03-04T21:44:31Z</dc:date>
    </item>
    <item>
      <title>Set analysis returns unexpected results</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240238#M90784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael, try this:&lt;/P&gt;&lt;P&gt;For the max date -&amp;gt; date(max(Date)&lt;/P&gt;&lt;P&gt;For the value associated -&amp;gt; firstsortedvalue(Amount,-Date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set analysis is not going to work in this case, since it is evaluated once per chart and not for every value within the domension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 22:32:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240238#M90784</guid>
      <dc:creator />
      <dc:date>2011-03-04T22:32:28Z</dc:date>
    </item>
    <item>
      <title>Set analysis returns unexpected results</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240239#M90785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ivan's solution should work if you don't actually need a sum, though you'll probably want to add a {1} to it if I understood your question.&lt;/P&gt;&lt;P&gt;If you DO need the sum, maybe this?&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;sum({1&amp;lt;Date={'$(=concat({1} aggr(max({1} Date),Year),chr(39) &amp;amp; ',' &amp;amp; chr(39)))'}&amp;gt;} Amount)&lt;/P&gt;&lt;P&gt;Yes, set analysis is only evaluated once per chart, but with the expression above (if I got it right), we generate a list of all the dates of interest. Only ONE of those dates will match each line in your chart, so everything will come out as expected in the end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 22:48:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240239#M90785</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-03-04T22:48:59Z</dc:date>
    </item>
    <item>
      <title>Set analysis returns unexpected results</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240240#M90786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes John is right, in case you need the sum of amount's that will be the expression to use, although I think there is missing a date conversion for the expression to work properly, like this:&lt;/P&gt;&lt;P&gt;sum({1&amp;lt;Date={'$(=concat({1} aggr(&lt;B&gt;date(&lt;/B&gt;max({1} Date)&lt;B&gt;)&lt;/B&gt;,Year),chr(39) &amp;amp; ',' &amp;amp; chr(39)))'}&amp;gt;} Amount)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2011 22:55:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240240#M90786</guid>
      <dc:creator />
      <dc:date>2011-03-04T22:55:58Z</dc:date>
    </item>
    <item>
      <title>Set analysis returns unexpected results</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240241#M90787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both Solutions works great !&lt;/P&gt;&lt;P&gt;I'm going to use the one with the sum since I get just a sample of the data, there might be multiple value ifor the Mac Date that must be summed probably in this case.&lt;/P&gt;&lt;P&gt;Thx guys,&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 05 Mar 2011 07:47:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-returns-unexpected-results/m-p/240241#M90787</guid>
      <dc:creator>agilos_mla</dc:creator>
      <dc:date>2011-03-05T07:47:27Z</dc:date>
    </item>
  </channel>
</rss>

