<?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: Issues with summing a calculated field in a pivot in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462246#M511954</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this should be working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum(aggr(sum(EUR)*(sum(KG)/sum(Total&amp;lt;Shipment&amp;gt;KG)), Shipment, City))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further it might be helpful to count the number of shipments and/or further to calculate the needed values already within the script, for example with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left join(InvoiceData)&lt;/P&gt;&lt;P&gt;load Shipment, count(Shipment) as ShipmentCount&lt;/P&gt;&lt;P&gt;resident ShipmentData group by Shipment;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jan 2018 12:09:56 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2018-01-11T12:09:56Z</dc:date>
    <item>
      <title>Issues with summing a calculated field in a pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462245#M511953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Qlikview Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm struggling with the following situation (simplified for the example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 4 shipments, some sent to one city, some sent to several cities (split delivery).&lt;/P&gt;&lt;P&gt;There is one table with the shipment number, the city and the quantity shipped (left table below).&lt;/P&gt;&lt;P&gt;There is another table with the shipment number and the invoiced amount in total (right table below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/189593_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;IMG alt="" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/189594_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both are separately loaded into Qlikview, creating this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/189595_pastedImage_2.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created three tables (see below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table 1 shows the loaded data.&lt;/P&gt;&lt;P&gt;As you can see, the Invoiced amount for shipment 101 is displayed in full at both Amsterdam and Rotterdam.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Table 2, I used the formula =sum(EUR)*(sum(KG)/sum(Total&amp;lt;Shipment&amp;gt;KG)) to created a split in Invoiced amount based on KG.&lt;/P&gt;&lt;P&gt;So far, so good, as it shows exactly what I want it to show.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Table 3, I set up a pivot to show me the totals per City.&lt;/P&gt;&lt;P&gt;However, the totals are wrong.&lt;/P&gt;&lt;P&gt;Amsterdam, for example, should be, based on Table 2: 15.000 + 17.500 + 5.000 = 37.500.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-4" src="https://community.qlik.com/legacyfs/online/189596_pastedImage_3.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;I've tried several approaches using aggr() and distinct(), but I just can't get it to work.&lt;/P&gt;&lt;P&gt;Can someone help me out here? I've attached the Qlikview Document for your convenience.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jan 2018 14:36:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462245#M511953</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-10T14:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with summing a calculated field in a pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462246#M511954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this should be working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum(aggr(sum(EUR)*(sum(KG)/sum(Total&amp;lt;Shipment&amp;gt;KG)), Shipment, City))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further it might be helpful to count the number of shipments and/or further to calculate the needed values already within the script, for example with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left join(InvoiceData)&lt;/P&gt;&lt;P&gt;load Shipment, count(Shipment) as ShipmentCount&lt;/P&gt;&lt;P&gt;resident ShipmentData group by Shipment;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2018 12:09:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462246#M511954</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2018-01-11T12:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with summing a calculated field in a pivot</title>
      <link>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462247#M511955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Marcus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks, the formula works like a charm! Does exactly what I want it to do, great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jan 2018 14:55:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issues-with-summing-a-calculated-field-in-a-pivot/m-p/1462247#M511955</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-11T14:55:00Z</dc:date>
    </item>
  </channel>
</rss>

