<?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 If statement on Set Analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640168#M1088065</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can somebody help?&amp;nbsp; I have two tables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;GroupA, ID&lt;/P&gt;&lt;P&gt;Employees-Male, 1&lt;/P&gt;&lt;P&gt;Employees-Female, 2&lt;/P&gt;&lt;P&gt;Managers, 3&lt;/P&gt;&lt;P&gt;T_Employees, 4&lt;/P&gt;&lt;P&gt;T_Managers, 5&lt;/P&gt;&lt;P&gt;Overall, 6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table2:&lt;/P&gt;&lt;P&gt;GroupB, ID, Count&lt;/P&gt;&lt;P&gt;Employees-Male, 1, 150&lt;/P&gt;&lt;P&gt;Employees-Female, 2,&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;Managers, 3,&amp;nbsp; 25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to get an expression on is if I select fields in Table1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Employees-Male - Count is 150&lt;/P&gt;&lt;P&gt;Employees-Female - Count is 200&lt;/P&gt;&lt;P&gt;Managers - Count is 25&lt;/P&gt;&lt;P&gt;T_Employees - Count is 350 (sum of male &amp;amp; female)&lt;/P&gt;&lt;P&gt;T_Managers - Count is 25 (Managers)&lt;/P&gt;&lt;P&gt;Overall - Count is 375 (all)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm thinking if statements in Set Analysis but not sure how to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already have this expression to begin with which outputs the count as field in Table1 is selected which solves the first three.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Table2= P(Table1)&amp;gt;} Count)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since Table2 is just a subset of Table1, the last three (&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;T_Employees, T_Managers, and &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Overall) is zero.&amp;nbsp; I probably need to add conditions (IF statements) to satisfy conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Jun 2014 22:35:08 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-06-04T22:35:08Z</dc:date>
    <item>
      <title>If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640168#M1088065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can somebody help?&amp;nbsp; I have two tables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;GroupA, ID&lt;/P&gt;&lt;P&gt;Employees-Male, 1&lt;/P&gt;&lt;P&gt;Employees-Female, 2&lt;/P&gt;&lt;P&gt;Managers, 3&lt;/P&gt;&lt;P&gt;T_Employees, 4&lt;/P&gt;&lt;P&gt;T_Managers, 5&lt;/P&gt;&lt;P&gt;Overall, 6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table2:&lt;/P&gt;&lt;P&gt;GroupB, ID, Count&lt;/P&gt;&lt;P&gt;Employees-Male, 1, 150&lt;/P&gt;&lt;P&gt;Employees-Female, 2,&amp;nbsp; 200&lt;/P&gt;&lt;P&gt;Managers, 3,&amp;nbsp; 25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I would like to get an expression on is if I select fields in Table1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Employees-Male - Count is 150&lt;/P&gt;&lt;P&gt;Employees-Female - Count is 200&lt;/P&gt;&lt;P&gt;Managers - Count is 25&lt;/P&gt;&lt;P&gt;T_Employees - Count is 350 (sum of male &amp;amp; female)&lt;/P&gt;&lt;P&gt;T_Managers - Count is 25 (Managers)&lt;/P&gt;&lt;P&gt;Overall - Count is 375 (all)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm thinking if statements in Set Analysis but not sure how to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I already have this expression to begin with which outputs the count as field in Table1 is selected which solves the first three.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Table2= P(Table1)&amp;gt;} Count)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since Table2 is just a subset of Table1, the last three (&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;T_Employees, T_Managers, and &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Overall) is zero.&amp;nbsp; I probably need to add conditions (IF statements) to satisfy conditions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jun 2014 22:35:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640168#M1088065</guid>
      <dc:creator />
      <dc:date>2014-06-04T22:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640169#M1088066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LIke this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jun 2014 23:05:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640169#M1088066</guid>
      <dc:creator />
      <dc:date>2014-06-04T23:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640170#M1088067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There's are few ways you can make this work, but my suggestion is for you to do this in the script as oppose to doing the calculation in the chart. In fact, you should be able to do this without using &lt;STRONG&gt;IF&lt;/STRONG&gt; statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What Dariusz suggested in his example in one way of doing it, and it uses an inline matrix to manage the GroupA to GroupB relationship.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Providing the &lt;STRONG&gt;ID&lt;/STRONG&gt; value doesn't change in you data, another way to do achieve this can done through code. S !ee example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;NOTE:&lt;/SPAN&gt; This method performs a full outer join on the 2 tables. For performance reason, this method may not be ideal if you're working with a very large data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 07:41:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640170#M1088067</guid>
      <dc:creator>shawn-qv</dc:creator>
      <dc:date>2014-06-05T07:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640171#M1088068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks like a good solution but it created a loop since I have 'month' as another column for both tables.&amp;nbsp; Any suggestion?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 17:37:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640171#M1088068</guid>
      <dc:creator />
      <dc:date>2014-06-05T17:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640172#M1088069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have not tried this but would this create a loop as Dariusz's approach?&amp;nbsp; I missed to mention that I have 'month' column in both tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 17:39:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640172#M1088069</guid>
      <dc:creator />
      <dc:date>2014-06-05T17:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640173#M1088070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're referring to my example, you can simply include the column "month" into Table1, and also all the concatenating loads in Table2 and you should be fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll see in my example that you only end up with one table in your data model (and not 2 tables), so you won't get any loops.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2014 23:23:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640173#M1088070</guid>
      <dc:creator>shawn-qv</dc:creator>
      <dc:date>2014-06-05T23:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640174#M1088071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried this but it created synthetic key which I'm trying to avoid.&amp;nbsp; Is there a way to do it in the expression with an if statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 16:16:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640174#M1088071</guid>
      <dc:creator />
      <dc:date>2014-06-06T16:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640175#M1088072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remove months from table1 and table 2 and put it only into my table3. I understand, that you connect ID1 and ID2 from the same month....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 16:38:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640175#M1088072</guid>
      <dc:creator />
      <dc:date>2014-06-06T16:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640176#M1088073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you want it to be done in expression then it will be&lt;/P&gt;&lt;P&gt;If(GroupA= 'T_Employees', $(=Sum({&amp;lt;GroupB= {'Employees-Female', 'Employees-Male'}&amp;gt;} Count)), If(GroupA='T_Managers', $(=Sum({&amp;lt;GroupB= {'Managers'}&amp;gt;} Count)), Sum(Count)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But preferrably you it should be done in script, I'm confused with your statement "Month field is in both tables".&lt;/P&gt;&lt;P&gt;Could you upload same file that your working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 16:41:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640176#M1088073</guid>
      <dc:creator>CELAMBARASAN</dc:creator>
      <dc:date>2014-06-06T16:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640177#M1088074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure how I can add the month column to table3.&amp;nbsp; It is just a relational table between tables 1 and 2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 16:43:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640177#M1088074</guid>
      <dc:creator />
      <dc:date>2014-06-06T16:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: If statement on Set Analysis</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640178#M1088075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it worked.&amp;nbsp; just had to delete the $ sign.&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;If(GroupA= 'T_Employees', Sum({&amp;lt;GroupB= {'Employees-Female', 'Employees-Male'}&amp;gt;} Count)), If(GroupA='T_Managers', Sum({&amp;lt;GroupB= {'Managers'}&amp;gt;} Count)), Sum(Count)))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 20:03:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-on-Set-Analysis/m-p/640178#M1088075</guid>
      <dc:creator />
      <dc:date>2014-06-06T20:03:26Z</dc:date>
    </item>
  </channel>
</rss>

