<?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: Average rank in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922735#M319557</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/laugh.png" /&gt; Let me work on this now...!&lt;/P&gt;&lt;P&gt;Is that OK if we can have solution at script level?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Aug 2015 13:28:43 GMT</pubDate>
    <dc:creator>MK_QSL</dc:creator>
    <dc:date>2015-08-13T13:28:43Z</dc:date>
    <item>
      <title>Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922730#M319552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to create an average rank calculation for the best days of every product. This is what I got this far:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QV.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/95943_QV.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I have the sales, and rank of each product for every day. So these numbers means for example that Product A was ranked 1 on 2015-09-01, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;2015-09-02 and &lt;SPAN style="font-size: 13.3333330154419px;"&gt;2015-09-03 for all products those days. And that expression looks like this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;aggr(rank(Sales),Date,Product)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do now is to calculate the average rank for the 10 best days for this product, and to remove the date field as dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So for Product A I only want one row like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="49" style="border: 1px solid #000000; width: 263px; height: 50px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Product&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Average rank&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Product A&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;2.7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And 2.7 here is calculated from:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;(1+1+1+2+2+2+3+4+5+6)/10 = 2.7&lt;/P&gt;&lt;P class="p1"&gt;&lt;/P&gt;&lt;P class="p1"&gt;How do I need to change my expression to be able to get this as a result?&lt;/P&gt;&lt;P class="p1"&gt;&lt;/P&gt;&lt;P class="p1"&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 12:38:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922730#M319552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T12:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922731#M319553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Provide sample data to work.. or sample application..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 12:52:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922731#M319553</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-08-13T12:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922732#M319554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's both a QVW-file and a spreadsheet with data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that it is not the exact same data as in my previous post, but the format is the same. &lt;/P&gt;&lt;P&gt;Since I only included 10 days in the data, we can take average rank of top 5 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So Product A in my example should generate (1+1+1+2+2)/5 = 1.4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:10:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922732#M319554</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922733#M319555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Kim but I am still not getting how you got &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;1+1+1+2+2.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Can you provide the logic behind this?&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:15:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922733#M319555</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-08-13T13:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922734#M319556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're looking at Product A and the ranks, you can see that it's been ranked at #1 for 3 days, and #2 for 2 days, right? So Product A has been the best seller for 3 of the days, among all products for those days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if I want to calculate the average rank for the top 5 highest ranked days for Product A, I would take (1+1+1+2+2)/5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that make sense? &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:22:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922734#M319556</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922735#M319557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/laugh.png" /&gt; Let me work on this now...!&lt;/P&gt;&lt;P&gt;Is that OK if we can have solution at script level?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:28:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922735#M319557</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-08-13T13:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922736#M319558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd rather have it in the expression since it can depend different dimensions/selections. But if you find a solution in the scripts that can work as well!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:31:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922736#M319558</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922737#M319559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it helps, I've manage to create an expression that gives me the average rank for the 5 days with highest sales for the product, like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;avg(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(aggr(rank(Sales),Product,Date)&amp;lt;6,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;aggr(rank(Sales),Date,Product),NULL()))&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;&lt;BR /&gt;&lt;/STRONG&gt;But I don't want the average rank for the top 5 selling days, I want the average rank for the top 5 days with the &lt;STRONG&gt;highest rank&lt;/STRONG&gt;. But it's close &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:40:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922737#M319559</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T13:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922738#M319560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CHECK !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 13:50:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922738#M319560</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2015-08-13T13:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922739#M319561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is your ranking is correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting different ranking. I am not sure if you are using any other logic&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 14:21:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922739#M319561</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2015-08-13T14:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922740#M319562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think mine is correct, yours seems to rank the days within each product. But I wan't to know the rank for all products for each day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in theory, one product could have rank 1 for all 10 days I have. But your logic gives every product a rank of 1-10 for the available days.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Aug 2015 14:30:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922740#M319562</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-13T14:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: Average rank</title>
      <link>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922741#M319563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks alot, that one actually works!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do think I need to do it in the expression though, and I've managed to do it like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;avg(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(aggr(rank(-aggr(rank(Sales),Date,Product)),Product,Date)&amp;lt;6,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;aggr(rank(Sales),Date,Product),NULL()))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which actually seems to be working, but I dot get some performance issues with all the ranks, ifs and aggregations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Aug 2015 06:27:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-rank/m-p/922741#M319563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-14T06:27:41Z</dc:date>
    </item>
  </channel>
</rss>

