<?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: count / sum Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429852#M160236</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's probably easiest if you could post a small sample (app or xls or inline data) to the forum, together with your expected outcome.&lt;/P&gt;&lt;P&gt;Do you want to calculate the expression in a chart (with what dimensions?) or in a text object?&lt;/P&gt;&lt;P&gt;How are the fields involved connected to each other?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2012 08:42:48 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-09-24T08:42:48Z</dc:date>
    <item>
      <title>count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429849#M160233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;sorry ... but i need help &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;hi had this function - works very well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;count({&amp;lt; MA_BAUREIHE = {'ELION','ELION_HYBRID','EVOS'} &amp;gt;}&amp;nbsp;&amp;nbsp; distinct BI_VERTRIEBSBELEG_NR&amp;amp;BI_VERKAUFSBELEG_POS ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;but now i have to add a filed with quantity: BI_MENGE. It means my count value * BI_MENGE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;I tried al lot off different things ... but nothing is working &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;Aggr(DISTINCT BI_VERTRIEBSBELEG_NR&amp;amp;BI_VERKAUFSBELEG_POS, sum (BI_MENGE ))&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px;"&gt;please help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 14:31:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429849#M160233</guid>
      <dc:creator />
      <dc:date>2012-09-21T14:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429850#M160234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We probably need to know where / in which context you are using this expression (this might include needing to know a bit about your data model).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a very simple case, you could try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; background-color: #eef4f9;"&gt;=count({&amp;lt; MA_BAUREIHE = {'ELION','ELION_HYBRID','EVOS'} &amp;gt;}&amp;nbsp;&amp;nbsp; distinct BI_VERTRIEBSBELEG_NR&amp;amp;BI_VERKAUFSBELEG_POS )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; background-color: #eef4f9;"&gt;* sum(BI_MENGE)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 14:41:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429850#M160234</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-21T14:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429851#M160235</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;no ... your formula give me a wrong result ... match to high &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what you must now about my data model ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 06:14:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429851#M160235</guid>
      <dc:creator />
      <dc:date>2012-09-24T06:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429852#M160236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's probably easiest if you could post a small sample (app or xls or inline data) to the forum, together with your expected outcome.&lt;/P&gt;&lt;P&gt;Do you want to calculate the expression in a chart (with what dimensions?) or in a text object?&lt;/P&gt;&lt;P&gt;How are the fields involved connected to each other?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 08:42:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429852#M160236</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-24T08:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429853#M160237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it a chart.&lt;/P&gt;&lt;P&gt;the formula creats the vaules you can see.&lt;/P&gt;&lt;P&gt;for example the last one 142 -&amp;gt; &lt;SPAN style="color: #636363; font-family: Arial; font-size: 12.800000190734863px; background-color: #eef4f9;"&gt;count({&amp;lt; MA_BAUREIHE = {'ELION','ELION_HYBRID','EVOS'} &amp;gt;}&amp;nbsp;&amp;nbsp; distinct BI_VERTRIEBSBELEG_NR&amp;amp;BI_VERKAUFSBELEG_POS )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="22406" class="jive-image-thumbnail jive-image" onclick="" alt="dia.jpg" src="https://community.qlik.com/legacyfs/online/22406_dia.jpg" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the data looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="22407" class="jive-image-thumbnail jive-image" onclick="" alt="dia2.jpg" src="https://community.qlik.com/legacyfs/online/22407_dia2.jpg" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but now i have 1 dimenson more &lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #eef4f9;"&gt;BI_MENGE&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 09:18:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429853#M160237</guid>
      <dc:creator />
      <dc:date>2012-09-24T09:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429854#M160238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume you are using one dimension right now, a Date dimension, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are doing a distinct count of BELEG_NR &amp;amp; BELEG_POS, I also assume that you could have multiple occurences of the same BELEG_NR &amp;amp; BELEG_POS on a single day, is this correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, could you also have different BI_MENGE for these records with identical BELEG_NR &amp;amp; BELEG_POS?&lt;/P&gt;&lt;P&gt;And how do you want to use the BI_MENGE then in your calculation? I am still missing an example with your expected outcome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 10:12:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429854#M160238</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-24T10:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429855#M160239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;swuehl schrieb:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you are using one dimension right now, a Date dimension, right?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;--&amp;gt; yes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are doing a distinct count of BELEG_NR &amp;amp; BELEG_POS, I also assume that you could have multiple occurences of the same BELEG_NR &amp;amp; BELEG_POS on a single day, is this correct?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;--&amp;gt; not a single day - but the same records over different months&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, could you also have different BI_MENGE for these records with identical BELEG_NR &amp;amp; BELEG_POS?&lt;/P&gt;&lt;P&gt;And how do you want to use the BI_MENGE then in your calculation? I am still missing an example with your expected outcome.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;--&amp;gt; yes the bi_menge can be different and shod be taken from the last run_date&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please have a look in to my test.qvw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks alot for your effort !&lt;/P&gt;&lt;P&gt;ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 15:11:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429855#M160239</guid>
      <dc:creator />
      <dc:date>2012-09-24T15:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429856#M160240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think we are getting closer. Your expression could probably look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=sum(aggr(FirstSortedValue(BI_MENGE,- KEY_LAUFDATUM_DATUM),BI_VERTRIEBSBELEG_NR))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This assumes that BELEG_NR is a valid dimension here in your case (in your sample, POS_NR was always identical).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in case you need the POS_NR, I think you need to create a field in your script defining your distinct dimension (you can't use a calculated dimension in the aggr() function, unfortunately) and then use this field as aggr() dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See also attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 15:28:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429856#M160240</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-24T15:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429857#M160241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; thats looking really well !&lt;/P&gt;&lt;P&gt;I need the POS_NR - it's not always 0100. i will make a new field with &lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #ffffff;"&gt;BELEG_NR &amp;amp; POS_NR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am back tomorrow &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks al lot&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 15:47:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429857#M160241</guid>
      <dc:creator />
      <dc:date>2012-09-24T15:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: count / sum Problem</title>
      <link>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429858#M160242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it's working nice !&lt;/P&gt;&lt;P&gt;Thanks a lot for your Help !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Beny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 06:55:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/count-sum-Problem/m-p/429858#M160242</guid>
      <dc:creator />
      <dc:date>2012-09-26T06:55:30Z</dc:date>
    </item>
  </channel>
</rss>

