<?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 with expressions in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262108#M397999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From what you have mentioned above, it seems that set analysis might not work for you. May be you need to use Aggr() function. But I am not 100% sure. Would you be able to provide a sample document with the expected output based on the sample provided?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Nov 2016 18:22:43 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-11-16T18:22:43Z</dc:date>
    <item>
      <title>set analysis with expressions</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262107#M397998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am trying to solve a problem with no sucess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have this dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="190" style="border: 1px solid rgb(0, 0, 0); width: 502px; height: 192px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Cod&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Control&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Problem&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;COD01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;A&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ID1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10/10/2016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD01&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ID2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;10/10/2016&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD01&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ID1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;14/10/2016&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD01&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;B&lt;BR /&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ID2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11/10/2016&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and i want to count the problems that are not closed after 3 days in point A.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex: i have 1 problem alive &lt;SPAN style="font-size: 13.3333px;"&gt;(14/10/2016 point B) &lt;/SPAN&gt;3 days after 10/10/2016 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to create a table with this output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="199" style="border: 1px solid rgb(0, 0, 0); width: 256px; height: 198px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Cod&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Problems&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;COD01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;83950&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD02&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;53882&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD03&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;77741&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD04&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;77354&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but my current result is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="199" style="border: 1px solid #000000; width: 256px; height: 198px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Cod&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Problems&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;COD01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;450&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD02&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;288&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD03&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;19761&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;COD04&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;77354&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my expression is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=count({&amp;lt; Control= {'B'}, &lt;STRONG&gt;Date&lt;/STRONG&gt;={"&amp;gt;=$(=(max( {$&amp;lt; Control={'A'}&amp;gt;}date)+3 ))"}&amp;gt;} Problem).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem i think i have is that my &lt;STRONG&gt;Date&lt;/STRONG&gt; field is with the value of the date of my last row (COD04) because the last row is correct. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think if i force the Cod on this expression, i obtain the correct result in the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible? something like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=count({&amp;lt; Control= {'B'}, Date={"&amp;gt;=$(=(max( {$&amp;lt; &lt;STRONG&gt;COD_BY_DIMENSION, &lt;/STRONG&gt;Control={'A'}&amp;gt;}date)+3 ))"}&amp;gt;} Problem).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thanks by your help &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2016 18:06:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262107#M397998</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-11-16T18:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis with expressions</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262108#M397999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From what you have mentioned above, it seems that set analysis might not work for you. May be you need to use Aggr() function. But I am not 100% sure. Would you be able to provide a sample document with the expected output based on the sample provided?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2016 18:22:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262108#M397999</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-11-16T18:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis with expressions</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262109#M398000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The quick answer is that set analysis expressions cannot be sensitive to dimensions so you can't do it the way you're trying to do it. There's technically a way around that, but it's hideously complex, and we don't need to go there for this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need to check the dates for each problem in each specific Cod. That's an aggr() by Cod and Problem.&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;aggr(...something...,Cod,Problem)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, what do we need for the "something"? It would need to return a count of 1 or a single problem ID if for that specific problem, the B point is &amp;gt; 2 days past the A point. So we want to say something like 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;if(Control B Date - Control A Date &amp;gt; 2, 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be good to use set analysis to identify the control B date and control A date of interest, in the name of performance. But didn't I just say we couldn't do that? Well, sort of, but not exactly. It's the set itself that is only evaluated once, but we can use a set expression where that's just fine. We need an aggregation function to use set analysis, so just in case there are multiple dates, I'll go with max() or min(). So I figure something like 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;if(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2, 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I tend to "cheat" with my Boolean algebra in a case like this. I know that an expression that is true evaluates to -1, false to 0. So I can rewrite the above as:&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;-(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know, I know, it doesn't save more than a couple characters, and is harder to read, but I'm just so used to seeing them that way. Do whichever makes you more comfortable. Anyway, we plug that into our aggr:&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;aggr(-(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2),Cod,Problem)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But we aren't done, because the aggr() will return multiple rows for each Cod. We want the count of those rows with a 1 on them. Easy enough, just sum, and that will give us that count.&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;sum(aggr(-(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2),Cod,Problem))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I typically put the - on the outside in a case like this, and then I doubt we'll need the inner parentheses around our Boolean expression:&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;&lt;SPAN&gt;-sum(&lt;SPAN&gt;aggr&lt;/SPAN&gt;(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2,Cod,Problem))&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I might have it wrong, but if I've understood your question and not made a mistake, that should work. That said, a more understandable version might read like 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(aggr(if(max({&amp;lt;Control={'B'}&amp;gt;} Date) - min({&amp;lt;Control={'A'}&amp;gt;} Date) &amp;gt; 2,Problem),Cod,Problem))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same basic idea, but now we're counting problems instead of negative summing a boolean expression, which is probably more clear. Clarity is good, and I have an unfortunate tendency to sacrifice it on the altar of brevity. Mea Culpa.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2016 21:03:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262109#M398000</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-11-16T21:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis with expressions</title>
      <link>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262110#M398001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you by your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understood your logic and your explanation. Amazing &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2016 09:24:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/set-analysis-with-expressions/m-p/1262110#M398001</guid>
      <dc:creator>vdcastro</dc:creator>
      <dc:date>2016-11-17T09:24:15Z</dc:date>
    </item>
  </channel>
</rss>

