<?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 Qty (Count Distinct Orders w/ Set Analysis) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41647#M7003</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know similar questions have been asked a number of times here, but I cannot find a solution that works for me...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a Table Object In order to count the number of distinct orders that fit certain criteria.&lt;/P&gt;&lt;P&gt;The Dimension is the Site.&lt;/P&gt;&lt;P&gt;I then have expressions like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=COUNT( DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &amp;gt;} ([ORDER_ID]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which work as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In another column in the Table Object, I need to calculate the Sum of Order Qty for per site, for all orders that fit the criteria.&lt;/P&gt;&lt;P&gt;So, in Excel, I'd have 5 columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Order_ID&lt;/P&gt;&lt;P&gt;Order_Qty&lt;/P&gt;&lt;P&gt;Shipped (filtered to "Null")&lt;/P&gt;&lt;P&gt;DueDate (filtered to "Null")&lt;/P&gt;&lt;P&gt;Flag (filtered to "1")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the Sum would be &lt;/P&gt;&lt;P&gt;I see that with this set, there are 14 distinct Order_IDs each with a Order_Qty of 100 and one ORDER_ID with a ORDER_QTY of 10. So the value I'm after is 1,410.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So back to the QV Expression, among other things, I tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=SUM(AGGR(COUNT(DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &amp;gt;} ([ORDER_ID]), ORDER_QTY))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I keep getting wayward results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Mar 2018 14:34:29 GMT</pubDate>
    <dc:creator>gramqlik</dc:creator>
    <dc:date>2018-03-16T14:34:29Z</dc:date>
    <item>
      <title>SUM Qty (Count Distinct Orders w/ Set Analysis)</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41647#M7003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know similar questions have been asked a number of times here, but I cannot find a solution that works for me...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a Table Object In order to count the number of distinct orders that fit certain criteria.&lt;/P&gt;&lt;P&gt;The Dimension is the Site.&lt;/P&gt;&lt;P&gt;I then have expressions like the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=COUNT( DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &amp;gt;} ([ORDER_ID]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which work as expected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In another column in the Table Object, I need to calculate the Sum of Order Qty for per site, for all orders that fit the criteria.&lt;/P&gt;&lt;P&gt;So, in Excel, I'd have 5 columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Order_ID&lt;/P&gt;&lt;P&gt;Order_Qty&lt;/P&gt;&lt;P&gt;Shipped (filtered to "Null")&lt;/P&gt;&lt;P&gt;DueDate (filtered to "Null")&lt;/P&gt;&lt;P&gt;Flag (filtered to "1")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the Sum would be &lt;/P&gt;&lt;P&gt;I see that with this set, there are 14 distinct Order_IDs each with a Order_Qty of 100 and one ORDER_ID with a ORDER_QTY of 10. So the value I'm after is 1,410.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So back to the QV Expression, among other things, I tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;=SUM(AGGR(COUNT(DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &amp;gt;} ([ORDER_ID]), ORDER_QTY))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I keep getting wayward results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:34:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41647#M7003</guid>
      <dc:creator>gramqlik</dc:creator>
      <dc:date>2018-03-16T14:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: SUM Qty (Count Distinct Orders w/ Set Analysis)</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41648#M7004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this may be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;=Sum(DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &amp;gt;} [Order Qty])&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2018 14:37:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41648#M7004</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-16T14:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: SUM Qty (Count Distinct Orders w/ Set Analysis)</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41649#M7005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DISTINCT was correct for counting the number of Orders, but there can be multiple records with the same ORDER_ID, but with different Order Qtys. I need to sum all quantities, not just those for distinct orders.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No matter what I try, I still seem to be getting wrong values.&lt;/P&gt;&lt;P&gt;For example, today I have 31 Orders (17 distinct). The Order Qty values for all 31 totals &lt;STRONG&gt;11,037&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the SUM DISTINCT you've suggested, it returns 311,977.&lt;/P&gt;&lt;P&gt;If I omit the DISTINCT, it returns 1,180,910.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use&lt;/P&gt;&lt;P&gt;=COUNT({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &lt;/SPAN&gt;&amp;gt;} &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Order_Qty&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;I get 1,622.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use&lt;/P&gt;&lt;P&gt;=SUM(AGGR(COUNT({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1} &lt;/SPAN&gt;&amp;gt;} ORDER_ID), &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Order_Qty&lt;/SPAN&gt;))&lt;/P&gt;&lt;P&gt;I get 1,036.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found that there is another field, ORDERLINEID, which I've added into my QVW. Say we have:&lt;/P&gt;&lt;P&gt;ORDER_ID = ABC123&lt;/P&gt;&lt;P&gt;ORDERLINEID = 1 , ORDER_QTY = 15&lt;/P&gt;&lt;P&gt;ORDERLINEID = 2 , ORDER_QTY = 10&lt;/P&gt;&lt;P&gt;ORDERLINEID = 3 , ORDER_QTY = 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ORDER_ID = DEF456&lt;/P&gt;&lt;P&gt;ORDERLINEID = 1 , ORDER_QTY = 20&lt;/P&gt;&lt;P&gt;ORDERLINEID = 2 , ORDER_QTY = 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm looking for 15 + 10 + 5 + 20 + 20 = 70&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2018 08:40:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41649#M7005</guid>
      <dc:creator>gramqlik</dc:creator>
      <dc:date>2018-03-19T08:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: SUM Qty (Count Distinct Orders w/ Set Analysis)</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41650#M7006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;=Sum(&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;{&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1}&amp;gt;} &lt;/STRONG&gt;Aggr(Sum(DISTINCT {&amp;lt;[Shipped] = {"Null"}, [DueDate] = {"Null"}, Flag = {1}&amp;gt;} [Order Qty]), ORDERLINEID))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2018 08:52:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41650#M7006</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-19T08:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: SUM Qty (Count Distinct Orders w/ Set Analysis)</title>
      <link>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41651#M7007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gah! Finally found the problem....... there was an error in my expression - I inadvertently the same field twice in the set analysis!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I had:&lt;/P&gt;&lt;P&gt;{&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;[Shipped]&lt;/STRONG&gt; = {"Null"}, &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;[Shipped]&lt;/STRONG&gt; = {"Null"}&lt;/SPAN&gt;, Flag = {1} &lt;/SPAN&gt;&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Buit should have had:&lt;/P&gt;&lt;P&gt;{&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;[Shipped]&lt;/STRONG&gt; = {"Null"}, &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;[Due Date]&lt;/STRONG&gt; = {"Null"}&lt;/SPAN&gt;, Flag = {1} &lt;/SPAN&gt;&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following works correctly without any DISTINCTs and AGGRs:&lt;/P&gt;&lt;P&gt;=SUM({&amp;lt;[&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Shipped&lt;/SPAN&gt;] = {"Null"}, [&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Due Date&lt;/SPAN&gt;] = {"Null"}, PalletFlag = {1}&amp;gt;} QTY_ORDERED) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help, Sunny.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2018 11:14:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SUM-Qty-Count-Distinct-Orders-w-Set-Analysis/m-p/41651#M7007</guid>
      <dc:creator>gramqlik</dc:creator>
      <dc:date>2018-03-19T11:14:41Z</dc:date>
    </item>
  </channel>
</rss>

