<?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: Dynamic pivot table column width in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460301#M171818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub&amp;nbsp; MySub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set val=ActiveDocument.Fields("Date").GetSelectedValues&lt;/P&gt;&lt;P&gt;ColCount = val.count&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set chart = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pwidths = chart.GetPixWidths(0,2).PixWidths&lt;/P&gt;&lt;P&gt;set fr = chart.GetFrameDef&lt;/P&gt;&lt;P&gt;set pos = fr.Rect&lt;/P&gt;&lt;P&gt;restwidth = pos.Width - pwidths(0) - pwidths(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColWidth = restwidth/ColCount&lt;/P&gt;&lt;P&gt;if ColWidth &amp;gt; 200 then ColWidth = 200&lt;/P&gt;&lt;P&gt;if ColWidth &amp;lt; 20 then ColWidth = 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chart.SetPixWidth val.count,ColWidth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Dec 2012 13:43:23 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2012-12-21T13:43:23Z</dc:date>
    <item>
      <title>Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460295#M171812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sirs&lt;/P&gt;&lt;P&gt;I have a pivot table with DATE as the horizontal dimension like a calender.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="27502" class="jive-image-thumbnail jive-image" height="540" onclick="" alt="Pivot_screenshot.JPG" src="https://community.qlik.com/legacyfs/online/27502_Pivot_screenshot.JPG" width="359" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to develop a macro which dynamically change the column width according to the number of dates that the user selects.&lt;/P&gt;&lt;P&gt;The goal is that the table always has the same total width of 2000 pixels (if more dates are selected =&amp;gt; columnwidth narrows and vice versa) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g.:&lt;/P&gt;&lt;P&gt;-if 91 days are selected =&amp;gt; columnwidth = 2000/91&lt;/P&gt;&lt;P&gt;-if 31 days are selected =&amp;gt; columnwidth = 2000/31&lt;/P&gt;&lt;P&gt;-minimum colum width = 20&lt;/P&gt;&lt;P&gt;-maximum column width = 200&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help with some macro skills? I believe I also have to define a variable like [count(distinct Date)] and somehow apply that variable in the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Merry xmas to all! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jesper &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 11:08:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460295#M171812</guid>
      <dc:creator />
      <dc:date>2012-12-21T11:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460296#M171813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This does what you asked for, but you'll probably end up with unreadable headers. Vertical headers seem to need about the same space as horizontal headers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub &lt;/P&gt;&lt;P&gt;set val=ActiveDocument.Fields("Date").GetSelectedValues&lt;/P&gt;&lt;P&gt;ColCount = val.count&lt;/P&gt;&lt;P&gt;ColWidth = 2000/ColCount&lt;/P&gt;&lt;P&gt;if ColWidth &amp;gt; 200 then ColWidth = 200&lt;/P&gt;&lt;P&gt;if ColWidth &amp;lt; 20 then ColWidth = 20&lt;/P&gt;&lt;P&gt;set chart = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;chart.SetPixWidth val.count,ColWidth&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 12:04:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460296#M171813</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2012-12-21T12:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460297#M171814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, I cant get it to work I think this line in the macro is the problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColWidth = 2000/ColCount&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need () og [] or somthing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 12:11:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460297#M171814</guid>
      <dc:creator />
      <dc:date>2012-12-21T12:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460298#M171815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or: is the problem that the selections are not made in the DATE field but in the YEAR and MONTH field? (with underlying date values)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 12:16:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460298#M171815</guid>
      <dc:creator />
      <dc:date>2012-12-21T12:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460299#M171816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It was - i nailed it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks mr. W&lt;/P&gt;&lt;P&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 12:18:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460299#M171816</guid>
      <dc:creator />
      <dc:date>2012-12-21T12:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460300#M171817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to develop a macro, that reads the total width of the pivot table (e.g. 2.200 pixels)&lt;/P&gt;&lt;P&gt;- deducts the column width of columns 1 and 2 (e.g. 150 pixels)&lt;/P&gt;&lt;P&gt;- uses the remaining 2.050 pixels in the above stated macro formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 13:24:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460300#M171817</guid>
      <dc:creator />
      <dc:date>2012-12-21T13:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460301#M171818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub&amp;nbsp; MySub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set val=ActiveDocument.Fields("Date").GetSelectedValues&lt;/P&gt;&lt;P&gt;ColCount = val.count&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set chart = ActiveDocument.GetSheetObject( "CH01" )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pwidths = chart.GetPixWidths(0,2).PixWidths&lt;/P&gt;&lt;P&gt;set fr = chart.GetFrameDef&lt;/P&gt;&lt;P&gt;set pos = fr.Rect&lt;/P&gt;&lt;P&gt;restwidth = pos.Width - pwidths(0) - pwidths(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColWidth = restwidth/ColCount&lt;/P&gt;&lt;P&gt;if ColWidth &amp;gt; 200 then ColWidth = 200&lt;/P&gt;&lt;P&gt;if ColWidth &amp;lt; 20 then ColWidth = 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;chart.SetPixWidth val.count,ColWidth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Dec 2012 13:43:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460301#M171818</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2012-12-21T13:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460302#M171819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For some reason i need to convert doc units to pixels so this one works.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set val=ActiveDocument.Fields("RessourceStartdato").GetPossibleValues&lt;BR /&gt;ColCount = val.count&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set chart = ActiveDocument.GetSheetObject("CH71")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pwidths = chart.GetPixWidths(0,2).PixWidths&lt;BR /&gt;set fr = chart.GetFrameDef&lt;BR /&gt;set pos = fr.Rect&lt;/P&gt;&lt;P&gt;restwidth = pos.Width/3.125 - pwidths(0) - pwidths(1) - 50&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ColWidth = restwidth/ColCount&lt;BR /&gt;if ColWidth &amp;gt; 200 then ColWidth = 200&lt;BR /&gt;if ColWidth &amp;lt; 20 then ColWidth = 20&lt;BR /&gt;chart.SetPixWidth val.count,ColWidth &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Dec 2012 15:46:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460302#M171819</guid>
      <dc:creator />
      <dc:date>2012-12-22T15:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic pivot table column width</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460303#M171820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert, this is an old discussion but relevant for me right now.&lt;/P&gt;&lt;P&gt;Im using your Macro suggestion, it's working great except when I clear selection.&lt;/P&gt;&lt;P&gt;When clearing selection the macro fails (I guess since ColCount= 0 and we devide by 0)&lt;/P&gt;&lt;P&gt;Im trying to overcome this by using GetPossibleCount in a variable and sending it to the function&lt;/P&gt;&lt;P&gt;but I cannot get it working..&lt;/P&gt;&lt;P&gt;I will appreciate your help here. See attached file. &lt;/P&gt;&lt;P&gt;CAdjust1 is using the variable while CAdjust is without (doesn't work when I clear all)&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;Ori&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Jul 2013 06:17:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-pivot-table-column-width/m-p/460303#M171820</guid>
      <dc:creator>orital81</dc:creator>
      <dc:date>2013-07-31T06:17:40Z</dc:date>
    </item>
  </channel>
</rss>

