<?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: Re: Grouping conditions in Set Analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685080#M248293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry but that sounds terrible for performance. I have WAY too much data to start writing sum(If()) expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I think I did find the syntax that will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that you can use parenthesis within the set analysis expression to do some grouping. So with some parenthesis and the intersection operator I was able to do what I wanted without having to repeat the time condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here is the syntax...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;$(TimeSetVar)&amp;gt; * &lt;STRONG&gt;(&lt;/STRONG&gt;1&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt;+ 1&amp;lt;Thing2 = {'arg3','arg4'}&amp;gt;&lt;STRONG&gt;)&lt;/STRONG&gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now for the explanation...&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;lt;$(TimeSetVar)&amp;gt; //This set uses a variable that overrides all calendar selections and sets the "master date" to a range&lt;/P&gt;&lt;P&gt;* //This is the intersection operator&lt;/P&gt;&lt;P&gt;( //Parenthesis to group the next two sets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt; //condition 1: notice I am starting with all the selections&lt;/P&gt;&lt;P&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;&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; // overridden this is just in case the selections are outside&lt;/P&gt;&lt;P&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;&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; // the limits of the "time set" in the first condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + //Union operator serves as the "OR" between the two sets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;lt;Thing2 = {'arg3','arg4'}&amp;gt; //Condition 2&lt;/P&gt;&lt;P&gt;) //Closing Parenthesis closes the group of conditions&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that makes sense, I'm going to figure out how to explain it better and blog about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attaching a sample that has a working but unfortunately kinda dumb example, the data is from the Wisconsis State trap meet, my kid is on the waterford team and I was playing with the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Aug 2014 12:53:25 GMT</pubDate>
    <dc:creator>chriscammers</dc:creator>
    <dc:date>2014-08-15T12:53:25Z</dc:date>
    <item>
      <title>Grouping conditions in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685078#M248291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some syntax that I'm not sure how to implement in set analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a series of set conditions that I am getting the union of like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt;+&amp;lt;Thing2 = {'arg1','arg2'}&amp;gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to add a condition that limits by time but I want it to apply to both parts of the union&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So a simple example would be to do something like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;Year = {'2014'},Thing1 = {'arg1','arg2'}&amp;gt;+&amp;lt;Year = {'2014'},Thing2 = {'arg1','arg2'}&amp;gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However my real expressions are WAY more complicated than this so I am wondering if there is syntax in set analysis that allows me to group these conditions similarly to the way you would use parenthesis in sql like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where Year = 2014 and ( Thing1 In ('arg1','arg2') OR Thing2 = ('arg1','arg2'))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I have used in the past an operator like -= to exclude values from a set like this...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;Year = {'2014'}, Month -={'January'}&amp;gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does the union Operator work the same way in this case?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;Year = {'2014'}, Month +={'January'}&amp;gt;}Sales)&lt;/P&gt;&lt;P&gt;So would this expression give me 2014&amp;nbsp; plus any january? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ugh, That's probably it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 16:36:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685078#M248291</guid>
      <dc:creator>chriscammers</dc:creator>
      <dc:date>2014-08-14T16:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping conditions in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685079#M248292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can maybe use a combination of If and set analysis like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Sum({&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt;+&amp;lt;Thing2 = {'arg1','arg2'}&amp;gt;}&amp;nbsp; if(Year=2014,Sales))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Also &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Sum({&amp;lt;Year = {'2014'}, Month +={'January'}&amp;gt;}Sales)&lt;/SPAN&gt; will just give every month plus Jan for Year 2014. So if there are no selections result will be all months in 2014. Say Dec is selected then Jan 2014 and Dec 2014 results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Attached is an example. The text box has the expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Thanks&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 17:46:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685079#M248292</guid>
      <dc:creator />
      <dc:date>2014-08-14T17:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Grouping conditions in Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685080#M248293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry but that sounds terrible for performance. I have WAY too much data to start writing sum(If()) expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I think I did find the syntax that will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that you can use parenthesis within the set analysis expression to do some grouping. So with some parenthesis and the intersection operator I was able to do what I wanted without having to repeat the time condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here is the syntax...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;$(TimeSetVar)&amp;gt; * &lt;STRONG&gt;(&lt;/STRONG&gt;1&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt;+ 1&amp;lt;Thing2 = {'arg3','arg4'}&amp;gt;&lt;STRONG&gt;)&lt;/STRONG&gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now for the explanation...&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;lt;$(TimeSetVar)&amp;gt; //This set uses a variable that overrides all calendar selections and sets the "master date" to a range&lt;/P&gt;&lt;P&gt;* //This is the intersection operator&lt;/P&gt;&lt;P&gt;( //Parenthesis to group the next two sets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;lt;Thing1 = {'arg1','arg2'}&amp;gt; //condition 1: notice I am starting with all the selections&lt;/P&gt;&lt;P&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;&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; // overridden this is just in case the selections are outside&lt;/P&gt;&lt;P&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;&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; // the limits of the "time set" in the first condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + //Union operator serves as the "OR" between the two sets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;lt;Thing2 = {'arg3','arg4'}&amp;gt; //Condition 2&lt;/P&gt;&lt;P&gt;) //Closing Parenthesis closes the group of conditions&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that makes sense, I'm going to figure out how to explain it better and blog about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm attaching a sample that has a working but unfortunately kinda dumb example, the data is from the Wisconsis State trap meet, my kid is on the waterford team and I was playing with the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Aug 2014 12:53:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Grouping-conditions-in-Set-Analysis/m-p/685080#M248293</guid>
      <dc:creator>chriscammers</dc:creator>
      <dc:date>2014-08-15T12:53:25Z</dc:date>
    </item>
  </channel>
</rss>

