<?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: Caculation of Total in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646855#M473847</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;Try like this in script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;If(Item &amp;lt;&amp;gt; Previous(Item), 1, 0) AS Flag;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Item,&lt;/P&gt;&lt;P&gt;Value,&lt;/P&gt;&lt;P&gt;Source&lt;/P&gt;&lt;P&gt;FROM DataSource&lt;/P&gt;&lt;P&gt;ORDER BY Item, Source;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now use this expression&lt;/P&gt;&lt;P&gt;=Sum({&amp;lt;Flag={1}&amp;gt;} Value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;jagan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Oct 2014 03:47:25 GMT</pubDate>
    <dc:creator>jagan</dc:creator>
    <dc:date>2014-10-17T03:47:25Z</dc:date>
    <item>
      <title>Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646852#M473844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone, I am encountering a calculation problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a simplified table:&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="border: 0px solid black;" width="52"&gt;item&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="93"&gt;value&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="55"&gt;Source&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;90&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-left: none; border-top: none;"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;100&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-left: none; border-top: none;"&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;50&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-left: none; border-top: none;"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-left: none; border-top: none;"&gt;60&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-left: none; border-top: none;"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The calculation rule is as follows:&lt;/P&gt;&lt;P&gt;for an Item that can be found in the source A(&amp;lt;&amp;gt;0), we should take the value from source A, otherwise we take the value from Source B.&lt;/P&gt;&lt;P&gt;If we find values from both source A(&amp;lt;&amp;gt;0) and B(&amp;lt;&amp;gt;0), we still take the value from source A.&lt;/P&gt;&lt;P&gt;The same logic applies where there are more sources.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can we get the right total by using a formula? In the above example, the total should be 100+50+60=210?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the formula I used but I don't get the right answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(sum({$&amp;lt;Source={'A'}&amp;gt;}[value])&amp;lt;&amp;gt;0,&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Source{'A'}&amp;gt;}[value]),&lt;/P&gt;&lt;P&gt;if(sum({$&amp;lt;Source={'B'}&amp;gt;}[value])&amp;lt;&amp;gt;0,&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Source={'B'}&amp;gt;}[value]),&lt;/P&gt;&lt;P&gt;if(sum({$&amp;lt;Source={'C'}&amp;gt;}[value])&amp;lt;&amp;gt;0,&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Source={'C'}&amp;gt;}[value])&lt;/P&gt;&lt;P&gt;)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 14:45:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646852#M473844</guid>
      <dc:creator />
      <dc:date>2014-10-16T14:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646853#M473845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;expression is&lt;/P&gt;&lt;P&gt;sum(aggr(subfield(Concat(value, '@', Source), '@', 1), item))&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/69130_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 20:05:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646853#M473845</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-10-16T20:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646854#M473846</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;one solution could be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_138154_Pic1.JPG.jpg" class="jive-image" src="https://community.qlik.com/legacyfs/online/69146_QlikCommunity_Thread_138154_Pic1.JPG.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 22:43:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646854#M473846</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2014-10-16T22:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646855#M473847</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;Try like this in script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;If(Item &amp;lt;&amp;gt; Previous(Item), 1, 0) AS Flag;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Item,&lt;/P&gt;&lt;P&gt;Value,&lt;/P&gt;&lt;P&gt;Source&lt;/P&gt;&lt;P&gt;FROM DataSource&lt;/P&gt;&lt;P&gt;ORDER BY Item, Source;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now use this expression&lt;/P&gt;&lt;P&gt;=Sum({&amp;lt;Flag={1}&amp;gt;} Value)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;jagan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 03:47:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646855#M473847</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2014-10-17T03:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646856#M473848</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;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Source={"=Sum([value]))&amp;lt;&amp;gt;0"}&amp;gt;}[value])&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 03:57:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646856#M473848</guid>
      <dc:creator>perumal_41</dc:creator>
      <dc:date>2014-10-17T03:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: Caculation of Total</title>
      <link>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646857#M473849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;It's great! However, I think I simplified too much my model here and I still can't figure out what I should do in my real life application, which is even more tricky:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -If the value is found in A, then we take this value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -If the values are found in B or C, we take the sum of them&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" style="border: 0px solid black;" width="52"&gt;item&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="93"&gt;value&lt;/TD&gt;&lt;TD class="xl63" style="border: 0px solid black; border-left: none;" width="55"&gt;Source&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-top: none; border-left: none;"&gt;90&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-top: none; border-left: none;"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;1&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-top: none; border-left: none;"&gt;100&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-top: none; border-left: none;"&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-top: none; border-left: none;"&gt;50&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-top: none; border-left: none;"&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;2&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-top: none; border-left: none;"&gt;40&lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-top: none; border-left: none;"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border: 0px solid black; border-top: none;"&gt;3&lt;/TD&gt;&lt;TD align="right" class="xl66" style="border: 0px solid black; border-top: none; border-left: none;"&gt;60 &lt;/TD&gt;&lt;TD class="xl64" style="border: 0px solid black; border-top: none; border-left: none;"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the result I would expect in my real life application is:&lt;/P&gt;&lt;P&gt;100+(50+40)+60=250&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would you advise?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 10:43:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Caculation-of-Total/m-p/646857#M473849</guid>
      <dc:creator />
      <dc:date>2014-10-17T10:43:46Z</dc:date>
    </item>
  </channel>
</rss>

