<?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: Sum over unique rows in expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894503#M311433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The {1} makes the expression ignore all selections. If that's not what you need then try removing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jun 2015 08:29:21 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2015-06-02T08:29:21Z</dc:date>
    <item>
      <title>Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894499#M311429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to calculate the percentage of stock that is obsolete in a gauge chart. I have two tables, one with the stock levels and one with sales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The stock table looks as follows:&lt;/P&gt;&lt;P&gt;product&amp;nbsp; stock&amp;nbsp;&amp;nbsp;&amp;nbsp; obsolete&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; YES&lt;/P&gt;&lt;P&gt;B &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO&lt;/P&gt;&lt;P&gt;C &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;200&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO&lt;/P&gt;&lt;P&gt;D &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;300&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have the following sales table:&lt;/P&gt;&lt;P&gt;product&amp;nbsp;&amp;nbsp; sold&lt;/P&gt;&lt;P&gt;B &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;20&lt;/P&gt;&lt;P&gt;B &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;30&lt;/P&gt;&lt;P&gt;B &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;45&lt;/P&gt;&lt;P&gt;C &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;10&lt;/P&gt;&lt;P&gt;C &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;100&lt;/P&gt;&lt;P&gt;D &lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I now calculate the sum in a graph expression, it contains many duplicates, I presume that this is the case due to Qlikview making the one-to-many relation between these tables (as expected in the rest of the dashboard, but not what I want here..). &lt;/P&gt;&lt;P&gt;The result here should be the sum of obsolete stock, divided by the total stock. In this case: 300/(300+200+200+300) = 30%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been messing around with aggregate, total, distinct, sum, min, but I cannot seem to get it right.. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anybody help me or point &lt;SPAN style="font-size: 13.3333330154419px;"&gt;me in the right direction?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Florian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:12:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894499#M311429</guid>
      <dc:creator />
      <dc:date>2015-06-02T08:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894500#M311430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try sum({&amp;lt;obsolete={'YES'}&amp;gt;}stock)/sum({1}total stock)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:15:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894500#M311430</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-06-02T08:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894501#M311431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, this works! This was a simplified example of something that I was actually trying to achieve, in which it does not work yet. So I probably have to look at the structure of the data there. &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sum({1}total stock) returns a value that is way too high there.. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:27:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894501#M311431</guid>
      <dc:creator />
      <dc:date>2015-06-02T08:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894502#M311432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the {1} set will mean that all data selections are ignored, which is why you are seeing a high figure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this, so the same selection apply to both expressions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt; sum({&amp;lt;obsolete={'YES'}&amp;gt;}stock) / sum(total stock)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:28:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894502#M311432</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2015-06-02T08:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894503#M311433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The {1} makes the expression ignore all selections. If that's not what you need then try removing it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:29:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894503#M311433</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-06-02T08:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894504#M311434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again for your suggestions, but I think I am doing something more fundamental wrong. Both &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sum({1}total stock) and &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sum(total stock) return a value that is about 320 times as high as the total stock actually is. Exporting the table (product, stock) to excel shows that the sum should be around 50.000, while the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;sum({1}total stock)&amp;nbsp; returns something like 13.000.000.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 08:42:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894504#M311434</guid>
      <dc:creator />
      <dc:date>2015-06-02T08:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894505#M311435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you get from this expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum({&amp;lt;obsolete={'YES'}&amp;gt;}stock) / sum(stock)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 09:09:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894505#M311435</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2015-06-02T09:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894506#M311436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Just sum(stock) gives a value of about 20.000, which is too low. I have attached my d&lt;/SPAN&gt;ata structure, maybe that gives you an idea of why these strange values are returned? If I create a table of 'newFinal', I get exactly the information I expect, and the total of the stock column is about 50.000 there, which is the value it should be.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="88145" alt="data structure.png" class="jive-image image-1" src="/legacyfs/online/88145_data structure.png" style="height: 289px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, by making a selection, the value for s&lt;SPAN style="font-size: 13.3333330154419px;"&gt;um(stock) can actually become higher?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 09:19:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894506#M311436</guid>
      <dc:creator />
      <dc:date>2015-06-02T09:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894507#M311437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest you remove the synthetic keys as it will make your data model easier to understand and test. With the synethic keys removed you will be able to preview the tables correctly and see if the data associations are correct.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 09:41:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894507#M311437</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2015-06-02T09:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894508#M311438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this tip! I managed to find the mistake in my document. I forgot to add 'distinct' to a load, where I should have added it. This caused some combinations to show up more than once in a table, but not in the table box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to you both for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 11:12:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894508#M311438</guid>
      <dc:creator />
      <dc:date>2015-06-02T11:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sum over unique rows in expression</title>
      <link>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894509#M311439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, glad you've fixed the problem &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can mark any helpful and correct answers to close the post this will help others searching on a similar issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jun 2015 12:23:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sum-over-unique-rows-in-expression/m-p/894509#M311439</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2015-06-02T12:23:16Z</dc:date>
    </item>
  </channel>
</rss>

