<?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 Pivot Table - Partial Sum in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219236#M72282</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmmm&lt;/P&gt;&lt;P&gt;i can see its working but i dont understand it jhon,&lt;/P&gt;&lt;P&gt;as far as i know an IF function returns null if the ELSE part is missing, so how come thers a value showing???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 10 Jul 2010 07:40:55 GMT</pubDate>
    <dc:creator>wizardo</dc:creator>
    <dc:date>2010-07-10T07:40:55Z</dc:date>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219233#M72279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a pivot table showing product family and quantity sold.&lt;/P&gt;&lt;P&gt;The product familes have different units e.g. Sawn has m3 whilst Machined as M.&lt;/P&gt;&lt;P&gt;For this reason I cannot show totals.&lt;/P&gt;&lt;P&gt;However, I would like to turn totals on if the user selects a combination of families where the quantity units are the same.&lt;/P&gt;&lt;P&gt;e.g. It is okay to show Sawn and Panels as we analyse the sales of these in m3.&lt;/P&gt;&lt;P&gt;I know how to work out if it is okay to show the totals order not but am unsure how to affect the "Show Partial Sums" tick box in the Pivot Table Properties | Presentation tab.&lt;/P&gt;&lt;P&gt;Think this will need to be done via a macro...&lt;/P&gt;&lt;P&gt;Any help greatly appreciated...&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 15:54:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219233#M72279</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2010-07-09T15:54:49Z</dc:date>
    </item>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219234#M72280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmm&lt;/P&gt;&lt;P&gt;hi paul&lt;/P&gt;&lt;P&gt;it is possible ....... but im not sure how elegant it looks&lt;/P&gt;&lt;P&gt;here is the recepie&lt;/P&gt;&lt;P&gt;first you create macro in the module editor&lt;/P&gt;&lt;P&gt;call it what ever you like ( i called it "partial_sum") an here is its contents:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub partial_sum&lt;BR /&gt;&lt;BR /&gt;' replace the field name with the field that hold the quantity units&lt;BR /&gt; set val=ActiveDocument.Fields("your field name").GetPossibleValues&lt;BR /&gt;' replace the object ID "CH02" with the object ID of your pivot&lt;BR /&gt; set chart = ActiveDocument.getsheetobject("CH02")&lt;BR /&gt; set cp = chart.GetProperties&lt;BR /&gt; set dims = cp.Dimensions&lt;BR /&gt;&lt;BR /&gt; if val.Count = 1 then&lt;BR /&gt; dims(1).ShowPartialSums = true 'show sums&lt;BR /&gt; chart.SetProperties cp&lt;BR /&gt; else&lt;BR /&gt;' replace the zero in dims(0) with the number of the dimension you want to toggle the partial sum (zero based)&lt;BR /&gt; dims(0).ShowPartialSums = false 'do not show sums&lt;BR /&gt; chart.SetProperties cp&lt;BR /&gt; end if&lt;BR /&gt;&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now go to the menu "setting / document properties " and select the "Triggers" tab&lt;/P&gt;&lt;P&gt;in the "Field Event Triggers" find your field and put the action "run macro" on both the "On Change" and "On Select" events&lt;/P&gt;&lt;P&gt;thats should do it&lt;/P&gt;&lt;P&gt;now when ever the user selections make it so that only one "quantity unit" is available the pivot will show partial sum&lt;/P&gt;&lt;P&gt;otherwise it will not&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope that helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 22:41:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219234#M72280</guid>
      <dc:creator>wizardo</dc:creator>
      <dc:date>2010-07-09T22:41:05Z</dc:date>
    </item>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219235#M72281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like it's even simpler than I'd have expected. Assuming you have a unit of measure associated with each product:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;if(len(UOM),sum(Amount))&lt;/P&gt;&lt;P&gt;See attached. Select a single product, or multiple products with the same unit of measure, and the partial sums will appear.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jul 2010 00:59:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219235#M72281</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-10T00:59:01Z</dc:date>
    </item>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219236#M72282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hmmmm&lt;/P&gt;&lt;P&gt;i can see its working but i dont understand it jhon,&lt;/P&gt;&lt;P&gt;as far as i know an IF function returns null if the ELSE part is missing, so how come thers a value showing???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jul 2010 07:40:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219236#M72282</guid>
      <dc:creator>wizardo</dc:creator>
      <dc:date>2010-07-10T07:40:55Z</dc:date>
    </item>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219237#M72283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like Wizardo, I can see that this is working but have no idea how...&lt;/P&gt;&lt;P&gt;Is it possible that you could talk us through what this is doing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Jul 2010 21:14:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219237#M72283</guid>
      <dc:creator>pkelly</dc:creator>
      <dc:date>2010-07-11T21:14:04Z</dc:date>
    </item>
    <item>
      <title>Pivot Table - Partial Sum</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219238#M72284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An if() statement doesn't require an else. And if without an else only returns null when the condition is false. It turns out that's exactly the behavior we need.&lt;/P&gt;&lt;P&gt;Let's look at what happens on the individual rows. At the detail level, every row has a UOM associated with it, so len(UOM) is &amp;gt; 0, which is interpreted as true (false=0, true=everything else), so we return sum(Amount). The detail rows will therefore always have the sum.&lt;/P&gt;&lt;P&gt;Now what about at the partial sum level? Well if EVERY row in the partial sum has the same UOM, then len(UOM) is still &amp;gt; 0, so we'll return sum(Amount), and we'll see the partial sum. But if ANY row in the partial sum has a different UOM, then there are multiple UOMs, so UOM will be null, so len(UOM) will be 0, which is interpreted as false, so we'll return the ELSE, but there is no ELSE, so we just return null. Nulls are then suppressed by default, so the partial sum row itself is then suppressed.&lt;/P&gt;&lt;P&gt;Now, in the data set I posted, every customer had every product. But let's say customer A only buys Cars and Widgets. The even if other customers buy other things, customer A will always show the partial sum since there is only one UOM associated with customer A. I'm guessing that's still the behavior you'd want, but I thought I'd mention it.&lt;/P&gt;&lt;P&gt;It might make things more clear if we wrote it like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;if(count(distinct UOM)=1,sum(Amount),null())&lt;/P&gt;&lt;P&gt;But the shorter version I used does exactly the same thing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jul 2010 17:41:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-Table-Partial-Sum/m-p/219238#M72284</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-12T17:41:36Z</dc:date>
    </item>
  </channel>
</rss>

