<?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 Sum aggr with double counting in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sum-aggr-with-double-counting/m-p/1535703#M439141</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to calculate the selling price of a products with this set of double counting data&lt;/P&gt;&lt;P&gt;saleid, interestid, saledate, interestdate, status, interestbu, systembu, source, and price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;selling process as below:&lt;/P&gt;&lt;P&gt;1. Book -&amp;gt; Return&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;2. Book -&amp;gt; Sign&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Book -&amp;gt; Sign -&amp;gt; Return&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;They cannot skip these process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there are also some conditions to fulfil.&lt;/P&gt;&lt;P&gt;1. interestbu and systembu must be from the same bu&lt;/P&gt;&lt;P&gt;2. Interestdate &amp;lt; saledate&lt;/P&gt;&lt;P&gt;3. saledate - interestdate &amp;lt; 0 and &amp;gt; 365&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i came up with the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If(status = 'Sign',
	sum({&amp;lt;source=&amp;gt;}
	if(systembu = interestbu, 
	if(interestdate &amp;lt; saledate, 
	if(saledate-interestdate &amp;gt; 0 
	and saledate-interestdate &amp;lt; 365, 
	Aggr(Only({&amp;lt;saleid = e({1&amp;lt;status = {'Return'}&amp;gt;})&amp;gt;}price),saleid))))),
If(status = 'Book' or status = 'Return',
	sum(
	if(systembu = interestbu,
	if(interestdate &amp;lt; saledate, 
	if(saledate-interestdate &amp;gt; 0 
	and saledate-interestdate &amp;lt; 365, 
	Aggr(price,saleid))))))) &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently, the problem i faced is whenever "Book" process doesnt fullfil the&amp;nbsp; conditions and dont appear when i select "Book", the id appear when i select "Sign" which is skip the selling process. I will attached sample qvw.&lt;/P&gt;&lt;P&gt;I have select the id "87311" as example. U can toggle between Status "Book" and "Sign" to see the problem.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 21:31:25 GMT</pubDate>
    <dc:creator>awalhashim</dc:creator>
    <dc:date>2024-11-16T21:31:25Z</dc:date>
    <item>
      <title>Sum aggr with double counting</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-aggr-with-double-counting/m-p/1535703#M439141</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to calculate the selling price of a products with this set of double counting data&lt;/P&gt;&lt;P&gt;saleid, interestid, saledate, interestdate, status, interestbu, systembu, source, and price.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;selling process as below:&lt;/P&gt;&lt;P&gt;1. Book -&amp;gt; Return&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;2. Book -&amp;gt; Sign&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Book -&amp;gt; Sign -&amp;gt; Return&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;They cannot skip these process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there are also some conditions to fulfil.&lt;/P&gt;&lt;P&gt;1. interestbu and systembu must be from the same bu&lt;/P&gt;&lt;P&gt;2. Interestdate &amp;lt; saledate&lt;/P&gt;&lt;P&gt;3. saledate - interestdate &amp;lt; 0 and &amp;gt; 365&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i came up with the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;If(status = 'Sign',
	sum({&amp;lt;source=&amp;gt;}
	if(systembu = interestbu, 
	if(interestdate &amp;lt; saledate, 
	if(saledate-interestdate &amp;gt; 0 
	and saledate-interestdate &amp;lt; 365, 
	Aggr(Only({&amp;lt;saleid = e({1&amp;lt;status = {'Return'}&amp;gt;})&amp;gt;}price),saleid))))),
If(status = 'Book' or status = 'Return',
	sum(
	if(systembu = interestbu,
	if(interestdate &amp;lt; saledate, 
	if(saledate-interestdate &amp;gt; 0 
	and saledate-interestdate &amp;lt; 365, 
	Aggr(price,saleid))))))) &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently, the problem i faced is whenever "Book" process doesnt fullfil the&amp;nbsp; conditions and dont appear when i select "Book", the id appear when i select "Sign" which is skip the selling process. I will attached sample qvw.&lt;/P&gt;&lt;P&gt;I have select the id "87311" as example. U can toggle between Status "Book" and "Sign" to see the problem.&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:31:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-aggr-with-double-counting/m-p/1535703#M439141</guid>
      <dc:creator>awalhashim</dc:creator>
      <dc:date>2024-11-16T21:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sum aggr with double counting</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-aggr-with-double-counting/m-p/1535915#M439150</link>
      <description>&lt;P&gt;For saleid 87311, interestbu is null for the row where interestdate &amp;lt; saledate which is why nothing is getting shown for status = Book&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 630px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/4619i5787FBCCBE007A5D/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could this be a data related issue?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 12:57:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-aggr-with-double-counting/m-p/1535915#M439150</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-01-28T12:57:33Z</dc:date>
    </item>
  </channel>
</rss>

