<?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: Macro to Sort Listbox dimension and expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782135#M1209598</link>
    <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/62450"&gt;@VivenReddy&lt;/a&gt;&amp;nbsp;, can you just create a straight table with youProduct as dimension, and one expression, with the same expression that you use in the list box?&lt;/P&gt;&lt;P&gt;With that, you just to double click over the Sales expression title to change the order of Products and use the Product colum to filter.&lt;/P&gt;&lt;P&gt;You can even add aselector for the Product column&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_2-1613076422748.png" style="width: 324px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48947i1C3F7B4DE7BF3824/image-dimensions/324x213?v=v2" width="324" height="213" role="button" title="QFabian_2-1613076422748.png" alt="QFabian_2-1613076422748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2021 20:47:10 GMT</pubDate>
    <dc:creator>QFabian</dc:creator>
    <dc:date>2021-02-11T20:47:10Z</dc:date>
    <item>
      <title>Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782085#M1209589</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VivenReddy_0-1613068114750.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48935iF7B08917C195E263/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VivenReddy_0-1613068114750.png" alt="VivenReddy_0-1613068114750.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need assistance in creating macros that will sort a listbox. One macro needs to sort the dimension (asc) and one macro should sort the expression (desc). I need to be able to switch between the 2 sorts using buttons.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A sample qvw has been attached.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 18:40:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782085#M1209589</guid>
      <dc:creator>VivenReddy</dc:creator>
      <dc:date>2021-02-11T18:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782118#M1209594</link>
      <description>&lt;P&gt;attached sample might be helpful although its not using any macro.&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 20:03:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782118#M1209594</guid>
      <dc:creator>Frank_Hartmann</dc:creator>
      <dc:date>2021-02-11T20:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782131#M1209597</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/62450"&gt;@VivenReddy&lt;/a&gt;&amp;nbsp; please try this macro, i used 'LB01'&amp;nbsp; as Id, becasue is the id from your example qvw&lt;/P&gt;&lt;P&gt;Dont forget to add a 'external\ run macro' action, using the macro name&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_0-1613075894821.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48945iBD34689C04ABC018/image-size/large?v=v2&amp;amp;px=999" role="button" title="QFabian_0-1613075894821.png" alt="QFabian_0-1613075894821.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let my know if it works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sub sort&lt;/STRONG&gt;&lt;BR /&gt;set LB = ActiveDocument.GetSheetObject("LB01")&lt;BR /&gt;set box=LB.GetProperties&lt;BR /&gt;if box.SortCriteria.SortByState = true then&lt;BR /&gt;box.SortCriteria.SortByState = false&lt;BR /&gt;else&lt;BR /&gt;box.SortCriteria.SortByState = true&lt;BR /&gt;end if&lt;BR /&gt;LB.SetProperties box&lt;BR /&gt;&lt;STRONG&gt;end sub&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 20:38:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782131#M1209597</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2021-02-11T20:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782135#M1209598</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/62450"&gt;@VivenReddy&lt;/a&gt;&amp;nbsp;, can you just create a straight table with youProduct as dimension, and one expression, with the same expression that you use in the list box?&lt;/P&gt;&lt;P&gt;With that, you just to double click over the Sales expression title to change the order of Products and use the Product colum to filter.&lt;/P&gt;&lt;P&gt;You can even add aselector for the Product column&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_2-1613076422748.png" style="width: 324px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/48947i1C3F7B4DE7BF3824/image-dimensions/324x213?v=v2" width="324" height="213" role="button" title="QFabian_2-1613076422748.png" alt="QFabian_2-1613076422748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 20:47:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1782135#M1209598</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2021-02-11T20:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783252#M1209739</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/29675"&gt;@Frank_Hartmann&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/121051"&gt;@QFabian&lt;/a&gt;&amp;nbsp;for your great suggestions. Unfortunately the example I posted did not match my use case. I've attached another example. See screenshot below. My listbox actually has 2 expressions and I need buttons to sort the expr 1 in ascending order and expr 2 in descending order. Is this possible?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VivenReddy_0-1613522897337.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/49181iFA7863A79E3F28B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VivenReddy_0-1613522897337.png" alt="VivenReddy_0-1613522897337.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 00:51:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783252#M1209739</guid>
      <dc:creator>VivenReddy</dc:creator>
      <dc:date>2021-02-17T00:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783254#M1209741</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/62450"&gt;@VivenReddy&lt;/a&gt;&amp;nbsp;, please check your updated qvw here attached, it has two macros associated in the&amp;nbsp; buttons.&lt;/P&gt;&lt;P&gt;Here the little macros, that can be found in APIGuide.qvw:&lt;/P&gt;&lt;P&gt;sub order1&lt;/P&gt;&lt;P&gt;set fld=ActiveDocument.GetField("Product")&lt;BR /&gt;set fldsrt = fld.GetDefaultSortCriteria&lt;BR /&gt;fldsrt.SortByExpression = 1&lt;BR /&gt;fldsrt.Expression.v = "only({&amp;lt;Product&amp;gt;}Description)"&lt;BR /&gt;fld.SetDefaultSortCriteria fldsrt&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;sub order2&lt;/P&gt;&lt;P&gt;set fld=ActiveDocument.GetField("Product")&lt;BR /&gt;set fldsrt = fld.GetDefaultSortCriteria&lt;BR /&gt;fldsrt.SortByExpression = 1&lt;BR /&gt;fldsrt.Expression.v = "sum({&amp;lt;Product&amp;gt;}Sales)"&lt;BR /&gt;fld.SetDefaultSortCriteria fldsrt&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;end sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let me know if this is an acceptable solution&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 02:10:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783254#M1209741</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2021-02-17T02:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783522#M1209770</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/121051"&gt;@QFabian&lt;/a&gt;.&amp;nbsp;I did see this in the APIGuide however I didnt think it would work for me for the following reasons:&lt;/P&gt;&lt;P&gt;1. The macro does not reference an object - so I was not sure how it would affect that field in the rest of my app.&lt;/P&gt;&lt;P&gt;2. What if the field in my listbox is an expression?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also noticed that your macro to sort the description is not working correctly. Is there an issue somewhere?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 16:40:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1783522#M1209770</guid>
      <dc:creator>VivenReddy</dc:creator>
      <dc:date>2021-02-17T16:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1784199#M1209839</link>
      <description>&lt;P&gt;see attached file&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 14:20:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1784199#M1209839</guid>
      <dc:creator>Frank_Hartmann</dc:creator>
      <dc:date>2021-02-19T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Sort Listbox dimension and expression</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1784294#M1209846</link>
      <description>&lt;P&gt;Thanks Frank - I did eventually implement your solution in my app.&lt;/P&gt;&lt;P&gt;If there is no other solution by next week I'll mark this as the solution.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 16:41:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Sort-Listbox-dimension-and-expression/m-p/1784294#M1209846</guid>
      <dc:creator>VivenReddy</dc:creator>
      <dc:date>2021-02-19T16:41:50Z</dc:date>
    </item>
  </channel>
</rss>

