<?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 Count Distinct based on another field in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167057#M38778</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I never thought of using the aggr() function. thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Aug 2010 12:09:31 GMT</pubDate>
    <dc:creator>gardan</dc:creator>
    <dc:date>2010-08-19T12:09:31Z</dc:date>
    <item>
      <title>Count Distinct based on another field</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167055#M38776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a sample of my data:&lt;/P&gt;&lt;P&gt;DeliveryID,Origin,Destination,ProductID,Quantity,Distance&lt;BR /&gt;33613333,US66,6100456,4055,540,40&lt;BR /&gt;33613344,US44,6100589,4055,240,84&lt;BR /&gt;33613344,US44,6100589,4003,300,84&lt;BR /&gt;33613355,USKL,6100666,4055,540,32&lt;BR /&gt;33613377,USPP,6100788,4003,250,76&lt;BR /&gt;33613377,USPP,6100788,4055,290,76&lt;/P&gt;&lt;P&gt;The first Delivery had 540 of Product 4055 on a truck that went 40 miles.&lt;/P&gt;&lt;P&gt;The second delivery had 240 of product 4055 and 300 of product 4003 on the truck that went 84 miles.&lt;/P&gt;&lt;P&gt;Now to count the number of loads, I can write the simple expression: &lt;EM&gt;Count(DISTINCT DeliveryID)&lt;/EM&gt; and the answer would be 4&lt;/P&gt;&lt;P&gt;My question is how is the best way to calculate the average distance the 4 deliveries ran.&lt;/P&gt;&lt;P&gt;If my expression is Avg(Distance) would it not weight those deliveries that delivered two diffent products twice as much as the ones that delivered one product?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Aug 2010 20:53:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167055#M38776</guid>
      <dc:creator>gardan</dc:creator>
      <dc:date>2010-08-18T20:53:29Z</dc:date>
    </item>
    <item>
      <title>Count Distinct based on another field</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167056#M38777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you could use the aggr function like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;aggr(avg(Distance), DeliveryID)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Which would return 58 (the average of the 4 unique trips) but you would also need to change your charts total mode to "average of rows" instead of expression total&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Aug 2010 21:16:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167056#M38777</guid>
      <dc:creator />
      <dc:date>2010-08-18T21:16:11Z</dc:date>
    </item>
    <item>
      <title>Count Distinct based on another field</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167057#M38778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I never thought of using the aggr() function. thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Aug 2010 12:09:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Distinct-based-on-another-field/m-p/167057#M38778</guid>
      <dc:creator>gardan</dc:creator>
      <dc:date>2010-08-19T12:09:31Z</dc:date>
    </item>
  </channel>
</rss>

