<?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 Pivot table with two calculated dimensions - rank() in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468602#M1152626</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question concerning two calculated dimensions in a pivot table (see file attached).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArtikelsGM you can find all sorts of articles.&lt;/P&gt;&lt;P&gt;In the pivot table I only want to show specific articles, as you can see. I managed to do this with if(match()) as a calculated dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is: I only want to show the top 3 of the sales (per Name)&lt;/P&gt;&lt;P&gt;So basically, the pivot table should only show me Name9, Name7 and Name4 (in that order)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to use the code below as another calculated dimension, but it does not seem to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=if(aggr(rank&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(sum(Sales))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,Name)&amp;lt;=3,Name)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you guys help me out?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Mar 2013 09:12:57 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-03-22T09:12:57Z</dc:date>
    <item>
      <title>Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468602#M1152626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question concerning two calculated dimensions in a pivot table (see file attached).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ArtikelsGM you can find all sorts of articles.&lt;/P&gt;&lt;P&gt;In the pivot table I only want to show specific articles, as you can see. I managed to do this with if(match()) as a calculated dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is: I only want to show the top 3 of the sales (per Name)&lt;/P&gt;&lt;P&gt;So basically, the pivot table should only show me Name9, Name7 and Name4 (in that order)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to use the code below as another calculated dimension, but it does not seem to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=if(aggr(rank&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(sum(Sales))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,Name)&amp;lt;=3,Name)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you guys help me out?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:12:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468602#M1152626</guid>
      <dc:creator />
      <dc:date>2013-03-22T09:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468603#M1152629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;try this&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rank:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD * INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name, sales&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a, 200&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b, 100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c, 300&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; d, 500&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e, 450&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f, 356&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression--&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(aggr(rank(sum(sales)),name)&amp;lt;=3,name)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or simply write this expression&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;aggr(if(rank(sum(sales))&amp;lt;=3,name),name)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;then output like this&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="614"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="57" width="98"&gt;name&lt;/TD&gt;&lt;TD class="xl64" style="border-left: none;" width="98"&gt;sales&lt;/TD&gt;&lt;TD class="xl66" width="418"&gt;&lt;BR /&gt; &lt;BR /&gt; if(aggr(rank(sum(sales)),name)&amp;lt;=3,name)&lt;BR /&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border-top: none;"&gt;d&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;500&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;d&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border-top: none;"&gt;e&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;450&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;e&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" style="border-top: none;"&gt;f&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;356&lt;/TD&gt;&lt;TD class="xl65" style="border-top: none; border-left: none;"&gt;f&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:41:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468603#M1152629</guid>
      <dc:creator />
      <dc:date>2013-03-22T09:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468604#M1152630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vishwaranjan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply, but I am a bit lost. I am pretty new to Qlikview and I only know expressions and dimensions.&lt;/P&gt;&lt;P&gt;Where should I enter the code written below?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rank:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD * INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name, sales&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a, 200&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b, 100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c, 300&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; d, 500&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e, 450&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f, 356&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the expressions you have given me, is this an expression or a calculated dimension?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Z&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 15:33:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468604#M1152630</guid>
      <dc:creator />
      <dc:date>2013-03-22T15:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468605#M1152632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this as calculated dimension:&lt;/P&gt;&lt;P&gt;=aggr( if(rank(aggr(sum({&amp;lt;ArtikelsGM={'42110 GIPS ZAKGOED','42210 GIPS SILO','42220 GIPS ZAK M'}&amp;gt;}Sales),Name))&amp;lt;=3,Name),Name)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The part {&amp;lt;ArtikelsGM={'42110 GIPS ZAKGOED','42210 GIPS SILO','42220 GIPS ZAK M'}&amp;gt;} is necessary because you 'select' these values in your other calculated dimension. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also use sum({&amp;lt;ArtikelsGM={'42110 GIPS ZAKGOED','42210 GIPS SILO','42220 GIPS ZAK M'}&amp;gt;} Sales) as expression and use ArtikelsGM as dimension instead of the calculated dimension. That's a better way to achieve the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached qvw.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 18:38:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468605#M1152632</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-03-22T18:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468606#M1152633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;firstly go to script--&lt;/P&gt;&lt;P&gt;then write this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rank:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD * INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name, sales&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a, 200&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b, 100&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c, 300&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; d, 500&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e, 450&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; f, 356&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;now on dashboard, right clik, and select new object---&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; select &lt;/STRONG&gt;&lt;STRONG&gt;pivote table.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;take &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dimension----&amp;nbsp; name , sales&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;expression----&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;if(aggr(rank(sum(sales)),name)&amp;lt;=3,name)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 05:33:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468606#M1152633</guid>
      <dc:creator />
      <dc:date>2013-03-25T05:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468607#M1152634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ vishwaranjan: Thank you for your help, I tried Gysbert's answer and it worked, so I perfer to not touch the script. But I tried yours in a test-file and it works as well. So many thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@ Gysbert: thank you for your reply, it works like a charm! Just one small qestion though:&lt;/P&gt;&lt;P&gt;Instead of "Sales", the formule to calculate my sales is a bit more complex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(&lt;STRONG&gt;{$&amp;lt;Jaar={$(=only(Jaar))}&amp;gt;} OmzetBedrag&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I enter this in your codes? I copied the bold part to put it at the&lt;EM&gt; Sales &lt;/EM&gt;part, but it did not work. How should I squeeze it in?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In calculated dimensions I now have;&lt;/P&gt;&lt;P&gt;=aggr( if(rank(aggr(sum({&amp;lt;ArtikelsGM={'42110 GIPS ZAKGOED','42210 GIPS SILO','42220 GIPS ZAK M'}&amp;gt;}Sales),Name))&amp;lt;=3,Name),Name)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in expressions I use;&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;ArtikelsGM={'42110 GIPS ZAKGOED','42210 GIPS SILO','42220 GIPS ZAK M'}&amp;gt;}Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So both times, the sales part should become &lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Jaar={$(=only(Jaar))}&amp;gt;} OmzetBedrag)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Zipke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 09:22:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468607#M1152634</guid>
      <dc:creator />
      <dc:date>2013-03-25T09:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pivot table with two calculated dimensions - rank()</title>
      <link>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468608#M1152635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright, I have found the solution.&lt;/P&gt;&lt;P&gt;Thanks for the help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Zipke&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 12:35:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Pivot-table-with-two-calculated-dimensions-rank/m-p/468608#M1152635</guid>
      <dc:creator />
      <dc:date>2013-03-26T12:35:42Z</dc:date>
    </item>
  </channel>
</rss>

