<?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: Sort via Macro question in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535032#M199898</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;Thank you for your response. Add another dim. to the macro as you suggested, it will sort the table but the primary sorting option will remain the second dimension. I need to sort primarily from the dim0 and secondarily from dim1. I find it easier to explain with examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I want to achieve:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" width="64"&gt;dim0&lt;/TD&gt;&lt;TD class="xl71" style="border-left: none;" width="64"&gt;dim1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what it does now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" width="64"&gt;dim0&lt;/TD&gt;&lt;TD class="xl73" style="border-left: none;" width="64"&gt;dim1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bogdan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Sep 2013 09:22:15 GMT</pubDate>
    <dc:creator>qlikplaut</dc:creator>
    <dc:date>2013-09-18T09:22:15Z</dc:date>
    <item>
      <title>Sort via Macro question</title>
      <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535030#M199896</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 am using a Macro to allow a button to sort a table using the first dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sub SortChart&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Set ch = ActiveDocument.GetSheetObject("CH01")&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; ch.SortBy 0 '' this line specifies the expression to sort by&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;EM&gt; Set p = ch.GetProperties&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Set dims = p.Dimensions&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; '' Dimensions start by 0&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; '' 0 = Disable sort&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; '' 1 = Sort ascending&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; '' -1 = Sort descending&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; i = dims.Item(0).SortCriteria.SortByNumeric&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; If i = 1 Then&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; dims.Item(0).SortCriteria.SortByNumeric = 1&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Else&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; dims.Item(0).SortCriteria.SortByNumeric = -1&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; End If&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; ch.SetProperties p&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;End Sub&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I have 2 dimensions in the table, I would like this macro to sort both of them, first sort using the first dimension and after using the second.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can do that from Chart Properties-&amp;gt; Sort, but I need to do it over this macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bogdan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 08:47:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535030#M199896</guid>
      <dc:creator>qlikplaut</dc:creator>
      <dc:date>2013-09-18T08:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sort via Macro question</title>
      <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535031#M199897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dims.Item(0) is the first dimension. If you want to sort another dimension add another if-then-else block for the second dimension using dims.Item(1). Or add them in the same block if you want to sort all the dimensions in the same order.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 09:10:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535031#M199897</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-09-18T09:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sort via Macro question</title>
      <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535032#M199898</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;Thank you for your response. Add another dim. to the macro as you suggested, it will sort the table but the primary sorting option will remain the second dimension. I need to sort primarily from the dim0 and secondarily from dim1. I find it easier to explain with examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I want to achieve:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" width="64"&gt;dim0&lt;/TD&gt;&lt;TD class="xl71" style="border-left: none;" width="64"&gt;dim1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl71" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl71" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what it does now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="128"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" width="64"&gt;dim0&lt;/TD&gt;&lt;TD class="xl73" style="border-left: none;" width="64"&gt;dim1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;a&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;b&lt;/TD&gt;&lt;TD align="right" class="xl73" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bogdan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 09:22:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535032#M199898</guid>
      <dc:creator>qlikplaut</dc:creator>
      <dc:date>2013-09-18T09:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sort via Macro question</title>
      <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535033#M199899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could change the order in which you applied this sorting or separate them in multiple executions - but perhaps you need only another SortCriteria - see this example from APIGuide.qvw:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rem set load order sort for all fields in chart Mychart&lt;/P&gt;&lt;P&gt;set chart=ActiveDocument.GetSheetObject("CH01")&lt;/P&gt;&lt;P&gt;set Prop = chart.GetProperties&lt;/P&gt;&lt;P&gt;set vars = Prop.Dimensions&lt;/P&gt;&lt;P&gt;for i = 0 to vars.Count-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vars.Item(i).SortCriteria.SortByAscii = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vars.Item(i).SortCriteria.SortByLoadOrder = 1&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;chart.SetProperties Prop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 11:28:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535033#M199899</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2013-09-18T11:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sort via Macro question</title>
      <link>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535034#M199900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your reply Marcus. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Might be sloppy, but I managed to make it work, here is what I used:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub SortChart&lt;/P&gt;&lt;P&gt; Set ch = ActiveDocument.GetSheetObject("CH01")&amp;nbsp; &lt;/P&gt;&lt;P&gt; ch.SortBy 1 '' this line specifies the expression to sort by&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Set p = ch.GetProperties&amp;nbsp; &lt;/P&gt;&lt;P&gt; Set dims = p.Dimensions&amp;nbsp; &lt;/P&gt;&lt;P&gt; '' Dimensions start by 0&amp;nbsp; &lt;/P&gt;&lt;P&gt; '' 0 = Disable sort&amp;nbsp; &lt;/P&gt;&lt;P&gt; '' 1 = Sort ascending&amp;nbsp; &lt;/P&gt;&lt;P&gt; '' -1 = Sort descending&amp;nbsp; &lt;/P&gt;&lt;P&gt; i = dims.Item(1).SortCriteria.SortByNumeric&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; If i = 1 Then&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; dims.Item(1).SortCriteria.SortByNumeric = -1&amp;nbsp; &lt;/P&gt;&lt;P&gt; Else&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; dims.Item(1).SortCriteria.SortByNumeric = 1&amp;nbsp; &lt;/P&gt;&lt;P&gt; End If&amp;nbsp; &lt;/P&gt;&lt;P&gt; ch.SetProperties p&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set ch = ActiveDocument.GetSheetObject("CH01")&amp;nbsp; &lt;/P&gt;&lt;P&gt; ch.SortBy 0 '' this line specifies the expression to sort by&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt; Set p = ch.GetProperties&amp;nbsp; &lt;/P&gt;&lt;P&gt; Set dims = p.Dimensions&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; i = dims.Item(0).SortCriteria.SortByNumeric&amp;nbsp; &lt;/P&gt;&lt;P&gt; If i = 1 Then&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; dims.Item(0).SortCriteria.SortByNumeric = -1&amp;nbsp; &lt;/P&gt;&lt;P&gt; Else&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; dims.Item(0).SortCriteria.SortByNumeric = 1&amp;nbsp; &lt;/P&gt;&lt;P&gt; End If&amp;nbsp; &lt;/P&gt;&lt;P&gt; ch.SetProperties p&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End Sub&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Sep 2013 12:49:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Sort-via-Macro-question/m-p/535034#M199900</guid>
      <dc:creator>qlikplaut</dc:creator>
      <dc:date>2013-09-18T12:49:01Z</dc:date>
    </item>
  </channel>
</rss>

