<?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: Aggregation with isnull and if in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880020#M307121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide 5 lines sample/dummy data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2015 11:35:02 GMT</pubDate>
    <dc:creator>MK_QSL</dc:creator>
    <dc:date>2015-06-23T11:35:02Z</dc:date>
    <item>
      <title>Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880019#M307120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having troubles trying to do some calculations, I hope someone could help me with it.&lt;/P&gt;&lt;H2&gt;&lt;/H2&gt;&lt;P&gt;I'm developing a table which shows Sales and another amounts like Fares and calculations between them The thing is if an order has a Fare then I want to show it and sum it, if not then I want to use the Sales amount instead. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is an example of the expected result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="100" style="border: 1px solid rgb(0, 0, 0); width: 304px; height: 95px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Region&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Sales&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Fare&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Fare1-Sales&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;160&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;150&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;275&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;C&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;250&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;365&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;115&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the expression I'm using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ISNULL(AGGR(&amp;nbsp; sum(Fare1), Order, Region))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AGGR(&amp;nbsp; sum(Fare1), Order, Region))&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that is showing the same amounts as the Sales, looks like the IF is not applying at order level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The datamodel is based on these tables, I've simplified it because I've seen other tables does not affect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Orders: Order, Sales, Region&lt;/P&gt;&lt;P&gt;- Fares: Order, Fare1, Fare2...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 11:33:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880019#M307120</guid>
      <dc:creator />
      <dc:date>2015-06-23T11:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880020#M307121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you provide 5 lines sample/dummy data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 11:35:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880020#M307121</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-06-23T11:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880021#M307122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've attached a very simple example, but it shows 2 differences from the original one,&lt;/P&gt;&lt;P&gt;- The example does not compare well using the isnull function, but it works comparing the aggr to 0.&lt;/P&gt;&lt;P&gt;- The example does not show the sales amounts on the calculated fields even when there is no fare.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the table by Region I've tried different combinations using the AGGR without luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 14:45:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880021#M307122</guid>
      <dc:creator />
      <dc:date>2015-06-23T14:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880022#M307123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In expression, you have to consider Null value as 0.&lt;/P&gt;&lt;P&gt;Also, there is no value associated with Order 2 and 5 so even if you uses IsNull(SUM(Sales)) you will get False.&lt;/P&gt;&lt;P&gt;So the method you have used as 0 is the right approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 15:11:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880022#M307123</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-06-23T15:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880023#M307124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to get the following table per Region:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="100" style="border: 1px solid #000000; width: 333px; height: 87px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Region&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Sales&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Calc&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;75&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;85&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;B&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;95&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;C&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A = 60 + 25&lt;/P&gt;&lt;P&gt;B = 85 + 40&lt;/P&gt;&lt;P&gt;C = 60&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if I do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ( AGGR( sum(Fare1), Order)=0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(Fare1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It gives me the sum(Fare1) for orders 1,3 and 4 but it does not sum the Sales for order 2 Why?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 15:21:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880023#M307124</guid>
      <dc:creator />
      <dc:date>2015-06-23T15:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880024#M307125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok...&lt;/P&gt;&lt;P&gt;Use Straight Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dimension&lt;/P&gt;&lt;P&gt;Region&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression&lt;/P&gt;&lt;P&gt;SUM(Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(Aggr(IF(SUM(Fare1) = 0, SUM(Sales),SUM(Fare1)),Order, Region))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 15:24:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880024#M307125</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-06-23T15:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880025#M307126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you do not have the order field in you table, QV will not take into account and will calculate the formula as a whole, so if one order has a 0/null it will consider as the whole region as a null &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use rangesum &lt;SPAN style="font-size: 13.3333330154419px;"&gt;instead&amp;nbsp; and apply a search in your set analysis &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RangeSum(&lt;/P&gt;&lt;P&gt;sum({&amp;lt;Order = {"=Sum(Fare1) = 0"}&amp;gt;}Sales),sum({&amp;lt;Order = {"=Sum(Fare1) &amp;lt;&amp;gt; 0"}&amp;gt;}Fare1))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 15:25:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880025#M307126</guid>
      <dc:creator>ramoncova06</dc:creator>
      <dc:date>2015-06-23T15:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregation with isnull and if</title>
      <link>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880026#M307127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both solutions solved the problem!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ramon I guess it works because it is aggregated at Order level and Region level as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks both!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2015 10:13:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggregation-with-isnull-and-if/m-p/880026#M307127</guid>
      <dc:creator />
      <dc:date>2015-06-25T10:13:42Z</dc:date>
    </item>
  </channel>
</rss>

