<?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 Macro to show/hide selected dimensions subtotals in the pivot table (list box) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-show-hide-selected-dimensions-subtotals-in-the-pivot/m-p/867541#M994726</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to write a macro that would show/hide subtotals for dimensions, that are selected from list box. I found a macro to show/hide subtotals for the table, that has regular dimensions (where you can't select which dimensions to show):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;' Show Subtotals&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;sub PivotShowSubtotals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set c = ActiveDocument.GetSheetObject("CH01")&lt;/P&gt;&lt;P&gt;set cp = c.GetProperties&lt;/P&gt;&lt;P&gt;set dims = cp.Dimensions&lt;/P&gt;&lt;P&gt;'set gp = chart.GetProperties&lt;/P&gt;&lt;P&gt;'set tp = gp.TableProperties&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;countexpr = cp.expressions.count 'count expressions&lt;/P&gt;&lt;P&gt;countdimexpanded = c.getcolumncount - countexpr 'count expanded dimensions&lt;/P&gt;&lt;P&gt;'msgbox(c.getcolumncount - countexpr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = 0 to countdimexpanded -1&lt;/P&gt;&lt;P&gt;j = i+1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Answer = MsgBox("Show Subtotals: Column "&amp;amp; j,3) '3 = yes, no, cancel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Answer=6 Then 'yes&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = true&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''' show total from dimension limit tab&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif Answer=7 Then 'no&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = false&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;exit for '(Answer=2) 'cancel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;' Hide Subtotals&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub PivotHideSubtotals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set c = ActiveDocument.GetSheetObject("CH01")&lt;/P&gt;&lt;P&gt;set cp = c.GetProperties&lt;/P&gt;&lt;P&gt;set dims = cp.Dimensions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = 0 to dims.Count -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = false&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I need a macro, which would show/hide subtotals for particular dimensions, selected from listbox.&lt;/P&gt;&lt;P&gt;Please, help me &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2015 08:09:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-07-14T08:09:06Z</dc:date>
    <item>
      <title>Macro to show/hide selected dimensions subtotals in the pivot table (list box)</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-show-hide-selected-dimensions-subtotals-in-the-pivot/m-p/867541#M994726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to write a macro that would show/hide subtotals for dimensions, that are selected from list box. I found a macro to show/hide subtotals for the table, that has regular dimensions (where you can't select which dimensions to show):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;' Show Subtotals&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;sub PivotShowSubtotals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set c = ActiveDocument.GetSheetObject("CH01")&lt;/P&gt;&lt;P&gt;set cp = c.GetProperties&lt;/P&gt;&lt;P&gt;set dims = cp.Dimensions&lt;/P&gt;&lt;P&gt;'set gp = chart.GetProperties&lt;/P&gt;&lt;P&gt;'set tp = gp.TableProperties&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;countexpr = cp.expressions.count 'count expressions&lt;/P&gt;&lt;P&gt;countdimexpanded = c.getcolumncount - countexpr 'count expanded dimensions&lt;/P&gt;&lt;P&gt;'msgbox(c.getcolumncount - countexpr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = 0 to countdimexpanded -1&lt;/P&gt;&lt;P&gt;j = i+1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Answer = MsgBox("Show Subtotals: Column "&amp;amp; j,3) '3 = yes, no, cancel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Answer=6 Then 'yes&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = true&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''' show total from dimension limit tab&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;elseif Answer=7 Then 'no&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = false&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;exit for '(Answer=2) 'cancel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;' Hide Subtotals&lt;/P&gt;&lt;P&gt;'***********************************************************************************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub PivotHideSubtotals&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set c = ActiveDocument.GetSheetObject("CH01")&lt;/P&gt;&lt;P&gt;set cp = c.GetProperties&lt;/P&gt;&lt;P&gt;set dims = cp.Dimensions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = 0 to dims.Count -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dims(i).ShowPartialSums = false&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c.SetProperties cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I need a macro, which would show/hide subtotals for particular dimensions, selected from listbox.&lt;/P&gt;&lt;P&gt;Please, help me &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 08:09:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-show-hide-selected-dimensions-subtotals-in-the-pivot/m-p/867541#M994726</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-14T08:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to show/hide selected dimensions subtotals in the pivot table (list box)</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-show-hide-selected-dimensions-subtotals-in-the-pivot/m-p/867542#M994727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have built such show/hide sub-totals with macros and wouldn't recommend to use such approach then it's not necessary - see: &lt;A href="https://community.qlik.com/qlik-blogpost/3700"&gt;Macros are Bad&lt;/A&gt; - you could gain the same if you doubled each of your dimensions within the chart - one with sub-totals and one without - and use visibility-conditions on these dimensions maybe per if(substringcount(getfieldselections(DimensionsWithSubTotals), 'Dimension1') &amp;gt;= 1, 1, 0). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are various examples available here in the community how you could show and hide dimensionss and expressions, maybe this one: &lt;A href="https://community.qlik.com/docs/DOC-3562"&gt;Hiding Dimensions in Pivot Table&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 14:56:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-show-hide-selected-dimensions-subtotals-in-the-pivot/m-p/867542#M994727</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-07-14T14:56:59Z</dc:date>
    </item>
  </channel>
</rss>

