<?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: Pivot table: sorting by expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072124#M1223668</link>
    <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46132"&gt;@simone_g&lt;/a&gt;&amp;nbsp; Pivot table sorting works on individual dimension, unfortunately there is no option to sort it by measure which is why sorting by expression also doesn't work as expected when you have multiple dimension. Hence, other option is to use calculated dimension as mentioned by&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6142"&gt;@Or&lt;/a&gt;&amp;nbsp; you can try below calculated dimension&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;=dual(Nation, aggr(sum(aggr(NODISTINCT rank(Product,4,1),Product)*1e5)+sum(Sales), Product,Nation))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then sort your calculated dimension by Numeric descending&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 23:35:08 GMT</pubDate>
    <dc:creator>Kushal_Chawda</dc:creator>
    <dc:date>2023-05-16T23:35:08Z</dc:date>
    <item>
      <title>Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071774#M1223643</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;
&lt;P&gt;I have a pivot table with two dimensions: Product and Nation. I need to calculate total sales per Product and Nation. For each product, nations should be sorted in decreasing order by expression:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sorting.PNG" style="width: 219px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107266i68F34FC92D127D25/image-size/large?v=v2&amp;amp;px=999" role="button" title="Sorting.PNG" alt="Sorting.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Please see the attachment. How should I change the pivot table to get the desired sorting?&lt;/P&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 09:02:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071774#M1223643</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T09:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071792#M1223644</link>
      <description>&lt;P&gt;You would need to set the second dimension to a custom sort and use an expression (descending) for sorting:&lt;/P&gt;
&lt;P&gt;=Aggr(Sum(Sales),Nation)&lt;/P&gt;
&lt;P&gt;Note that this will be hard-coded to the dimension and measure in question, so it won't work if you use cyclic groups, dynamic pivots, or anything of that nature.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 09:37:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071792#M1223644</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-05-16T09:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071822#M1223646</link>
      <description>&lt;P&gt;I tried your expression for sorting but I am not getting the desired order.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Expression.PNG" style="width: 811px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107276i0586167EE8A9CF88/image-size/large?v=v2&amp;amp;px=999" role="button" title="Expression.PNG" alt="Expression.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Are you sure the expression works? Am I missing something?&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 10:20:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071822#M1223646</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T10:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071853#M1223650</link>
      <description>&lt;P&gt;Assuming your measure is Sum(Sales) and your dimension is Nation, it should work (though you should remove the Stato checkbox first). If your measure is something else, this should match your measure.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 11:49:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071853#M1223650</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-05-16T11:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071862#M1223651</link>
      <description>&lt;P&gt;Actually I have two dimensions: Product and Nation.&lt;/P&gt;
&lt;P&gt;I removed the Stato checkbox but it still does not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:01:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071862#M1223651</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T12:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071866#M1223652</link>
      <description>&lt;P&gt;Ah, I neglected to include Product.&lt;/P&gt;
&lt;P&gt;=Aggr(Sum(Sales),Product,Nation)&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:02:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071866#M1223652</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-05-16T12:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071868#M1223653</link>
      <description>&lt;P&gt;Unfortunately, it still does not work. See attached document.&lt;/P&gt;
&lt;P&gt;My measure is Sum(Sales). Nations are ordered in the same way for each Product. Nations are ordered according to overall sales regardless of the product.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:14:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071868#M1223653</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T12:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071897#M1223655</link>
      <description>&lt;P&gt;What is the sort order for Product? It should be set to either numeric or text (or both).&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:44:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071897#M1223655</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-05-16T12:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071900#M1223656</link>
      <description>&lt;P&gt;It is set to numeric, increasing.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 12:50:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071900#M1223656</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T12:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071916#M1223657</link>
      <description>&lt;P&gt;I'm probably missing something obvious here, but you are correct in that it does not work as expected.&lt;/P&gt;
&lt;P&gt;As a workaround, you can use a calculated dimension with this sort order. Otherwise, perhaps someone else can figure out what I'm overlooking and fix it with just the sort order.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Or_1-1684242329920.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107286iC2575539BAE51D1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Or_1-1684242329920.png" alt="Or_1-1684242329920.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>Tue, 16 May 2023 13:05:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2071916#M1223657</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2023-05-16T13:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072023#M1223663</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;I tried your expression with Dual but it creates duplicates. For example, I get 2 rows for France for product 2.&amp;nbsp; Moreover, there is no row for Germany. I am not sure how I shoud sort the calculated dimension in the sorting menu.&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 16:05:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072023#M1223663</guid>
      <dc:creator>simone_g</dc:creator>
      <dc:date>2023-05-16T16:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072124#M1223668</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46132"&gt;@simone_g&lt;/a&gt;&amp;nbsp; Pivot table sorting works on individual dimension, unfortunately there is no option to sort it by measure which is why sorting by expression also doesn't work as expected when you have multiple dimension. Hence, other option is to use calculated dimension as mentioned by&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6142"&gt;@Or&lt;/a&gt;&amp;nbsp; you can try below calculated dimension&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;=dual(Nation, aggr(sum(aggr(NODISTINCT rank(Product,4,1),Product)*1e5)+sum(Sales), Product,Nation))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then sort your calculated dimension by Numeric descending&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 23:35:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072124#M1223668</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2023-05-16T23:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table: sorting by expression</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072160#M1223671</link>
      <description>&lt;P&gt;Hi Simone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PFA, use the dual while loading data. -Doesn't make sense logically but does the trick.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 03:58:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-sorting-by-expression/m-p/2072160#M1223671</guid>
      <dc:creator>vamsee</dc:creator>
      <dc:date>2023-05-17T03:58:07Z</dc:date>
    </item>
  </channel>
</rss>

