<?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 Count Rank in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214103#M67689</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've attached an update chart - should be just a case of totalling the last column...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Jul 2010 09:56:20 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-07-05T09:56:20Z</dc:date>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214102#M67688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I need your help..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to show, how many times a branch is in top 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please helpp..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Jul 2010 09:01:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214102#M67688</guid>
      <dc:creator />
      <dc:date>2010-07-05T09:01:00Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214103#M67689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've attached an update chart - should be just a case of totalling the last column...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Jul 2010 09:56:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214103#M67689</guid>
      <dc:creator />
      <dc:date>2010-07-05T09:56:20Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214104#M67690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your helpfulness..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I should use with aggregate function. Otherwise I can not show results for both years and branches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I m looking for your suggestions..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Jul 2010 10:25:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214104#M67690</guid>
      <dc:creator />
      <dc:date>2010-07-05T10:25:36Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214105#M67691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To produce the chart you requested:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;Dimension 1 = branchName&lt;BR /&gt;Dimension 2 = aggr(-sum(aggr(rank(sum(profit))&amp;lt;4,year,branchName)),branchName)&lt;BR /&gt;Dimension 3 = year&lt;BR /&gt;Expression = if(aggr(rank(sum(profit)),year,branchName)&amp;lt;4&lt;BR /&gt; ,aggr(rank(sum(profit)),year,branchName))&lt;/P&gt;&lt;P&gt;See attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jul 2010 19:28:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214105#M67691</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-06T19:28:33Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214106#M67692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply, This was exactly what I want to do.&lt;/P&gt;&lt;P&gt;I had lost hope of solving this problem, I am grateful to you, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you explain the 2 nd dimension if you have time?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jul 2010 15:22:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214106#M67692</guid>
      <dc:creator />
      <dc:date>2010-07-07T15:22:06Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214107#M67693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;aggr(-sum(aggr(rank(sum(profit))&amp;lt;4,year,branchName)),branchName)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;OK, we need to work from the inside to the outside on this one.&lt;/P&gt;&lt;P&gt;Let's start with this part:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(rank(sum(profit))&amp;lt;4,year,branchName)&lt;/P&gt;&lt;P&gt;And let's first consider a simpler case, this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(sum(profit),year,branchName)&lt;/P&gt;&lt;P&gt;An aggregation is like an internal chart. In this case, it's like we have an internal chart with two dimensions, year and branchName. For each year and branch name, we want to calculate the total profit. Think of it as a pivot table with branchName on the left and year on the top. Go ahead and built it if you want to see it. That's what the aggr() is doing.&lt;/P&gt;&lt;P&gt;Then we add in the rank() function:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(rank(sum(profit)),year,branchName)&lt;/P&gt;&lt;P&gt;This pivot table IS in the posted example, the top left chart. So this is what the aggr() is doing internally, without actually building a chart, ranking branchNames by the sum(profit) for each year.&lt;/P&gt;&lt;P&gt;Now, we only want to track the top three ranks. That can be expressed like this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(if(rank(sum(profit))&amp;lt;4,rank(sum(profit))),year,branchName)&lt;/P&gt;&lt;P&gt;And I just realized that the expression in the final chart can be written like that rather than how I wrote it in the example, which should simplify things a little. However, for the purpose of counting, we don't care WHAT the rank actually is, only that it is in the range of 1-3. So we can simplify to this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(if(rank(sum(profit))&amp;lt;4,1,0),year,branchName)&lt;/P&gt;&lt;P&gt;So if rank(sum(profit))&amp;lt;4, it returns 1, otherwise it returns 0. However, in QlikView, true is -1 and false is 0. So the condition itself, without an if(), will return -1 or 0. That lets us simplify to this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(-(rank(sum(profit))&amp;lt;4),year,branchName)&lt;/P&gt;&lt;P&gt;But it's inefficient to take the negative for every "row and column" in our table. So we'll remove it for now, and just remember that our number is currently negative instead of positive, and we'll have to fix that. That brings us to the sub-expression we started with:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(rank(sum(profit))&amp;lt;4,year,branchName)&lt;/P&gt;&lt;P&gt;Now let's look at our second aggregation:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;aggr(-sum(...),branchName)&lt;/P&gt;&lt;P&gt;The expression we already made goes where the "..." are. So this second aggr() is using a data set which is an internal table of each year and branchName, with a value of -1 or 0 depending on whether it's top three ranked that year or not. So THIS aggr() then takes that data, groups by branchName, sums up the -1s, and then fixes the sign. What it produces, then, is an internal table of branchName vs. the count of the number of years that branch has been in the top 3 for profit. Since our REAL chart has branchName as the first real dimension, that maps to only one row of this internal table, and therefore it returns ONLY the matching count of years. Oh, and I probably should have put the minus sign all the way on the outside:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;-aggr(sum(aggr(rank(sum(profit))&amp;lt;4,year,branchName)),branchName)&lt;/P&gt;&lt;P&gt;So then the slightly-simplified chart would be this:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;Dimension 1 = branchName&lt;BR /&gt;Dimension 2 = -aggr(sum(aggr(rank(sum(profit))&amp;lt;4,year,branchName)),branchName)&lt;BR /&gt;Dimension 3 = year&lt;BR /&gt;Expression = aggr(if(rank(sum(profit))&amp;lt;4,rank(sum(profit))),year,branchName)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jul 2010 17:31:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214107#M67693</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-07T17:31:19Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214108#M67694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is so clear, thank you very much.&lt;/P&gt;&lt;P&gt;I will keep this text as a lecture note on aggr and rank functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jul 2010 09:20:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214108#M67694</guid>
      <dc:creator />
      <dc:date>2010-07-08T09:20:02Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214109#M67695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, John !&lt;/P&gt;&lt;P&gt;If I want to show, how many times a branch is in first position sequentially ?&lt;/P&gt;&lt;P&gt;I`m a newbie on Qlikview and I need and want to learn it.&lt;/P&gt;&lt;P&gt;Best Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Jul 2010 22:05:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214109#M67695</guid>
      <dc:creator />
      <dc:date>2010-07-09T22:05:22Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214110#M67696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;Mombuca01 wrote:If I want to show, how many times a branch is in first position sequentially ?&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I don't understand the question. If we use the sample data we were given, what sort of output chart are you asking for?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jul 2010 00:18:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214110#M67696</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-07-10T00:18:18Z</dc:date>
    </item>
    <item>
      <title>Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214111#M67697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Example: Ray was #1 for 2 times in sequentially....&lt;/P&gt;&lt;P&gt;Position Name&lt;/P&gt;&lt;P&gt;1 Paul&lt;/P&gt;&lt;P&gt;1 Ray&lt;/P&gt;&lt;P&gt;1 Ray&lt;/P&gt;&lt;P&gt;1 Paul&lt;/P&gt;&lt;P&gt;1 Ray&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Jul 2010 03:35:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214111#M67697</guid>
      <dc:creator />
      <dc:date>2010-07-10T03:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count Rank</title>
      <link>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214112#M67698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai Please Find The Attach ment&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Oct 2012 10:07:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-Rank/m-p/214112#M67698</guid>
      <dc:creator />
      <dc:date>2012-10-16T10:07:00Z</dc:date>
    </item>
  </channel>
</rss>

