<?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 Ranking with Aggr() per region in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Ranking-with-Aggr-per-region/m-p/1880322#M72550</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm working on an app with a complicated data model. I have two expressions. The first one displays the ranking of products based on number of orders. The second one displays ranking based on customer's rating.&lt;/P&gt;
&lt;P&gt;The first one is something like this:&lt;BR /&gt;&lt;EM&gt;Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct {&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},flag={1}&amp;gt;} [Counter Field])&amp;gt;=vThreshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Sum({&amp;lt;flag={1}&amp;gt;}Aggr(Sum({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;flag={1}&amp;gt;}ValueField)*if(vType='Quantity',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;sum({&amp;lt;flag={1}&amp;gt;}[Regional sales Weight])&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Counter Field],ProductId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),4,1),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Region,ProductId)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The second one is:&lt;BR /&gt;&lt;EM&gt;Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct{&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;} [Counter Field])&amp;gt;=vValue_Threshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={4,5}&amp;gt;}Rating) / &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;}Rating))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;-&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={1,2}&amp;gt;}Rating) / &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;}Rating))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,4,1)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,ProductId)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;My goal is to make a sheet, where user can see stats per selected product ID. The first expression was reworked to look like this:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;max({&amp;lt;ProductId = {Id1}&amp;gt;}&lt;/STRONG&gt; Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct {&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},flag={1}&amp;gt;} [Counter Field])&amp;gt;=vThreshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Sum({&amp;lt;flag={1}&amp;gt;}Aggr(Sum({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;flag={1}&amp;gt;}ValueField)*if(vType='Quantity',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;sum({&amp;lt;flag={1}&amp;gt;}[Regional sales Weight])&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Counter Field],ProductId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),4,1),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Region,&lt;/STRONG&gt;ProductId)&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It works fine and I can see the correct ranking per region for the selected product ID. However, if I try to rework the second expression using the same approach, it doesn't work. Do you have any ideas why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 18:27:13 GMT</pubDate>
    <dc:creator>Primrose</dc:creator>
    <dc:date>2022-01-12T18:27:13Z</dc:date>
    <item>
      <title>Ranking with Aggr() per region</title>
      <link>https://community.qlik.com/t5/App-Development/Ranking-with-Aggr-per-region/m-p/1880322#M72550</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm working on an app with a complicated data model. I have two expressions. The first one displays the ranking of products based on number of orders. The second one displays ranking based on customer's rating.&lt;/P&gt;
&lt;P&gt;The first one is something like this:&lt;BR /&gt;&lt;EM&gt;Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct {&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},flag={1}&amp;gt;} [Counter Field])&amp;gt;=vThreshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Sum({&amp;lt;flag={1}&amp;gt;}Aggr(Sum({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;flag={1}&amp;gt;}ValueField)*if(vType='Quantity',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;sum({&amp;lt;flag={1}&amp;gt;}[Regional sales Weight])&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Counter Field],ProductId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),4,1),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Region,ProductId)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The second one is:&lt;BR /&gt;&lt;EM&gt;Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct{&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;} [Counter Field])&amp;gt;=vValue_Threshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={4,5}&amp;gt;}Rating) / &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;}Rating))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;-&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;(Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={1,2}&amp;gt;}Rating) / &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Count({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quality'},Rating={"&amp;gt;0"}&amp;gt;}Rating))&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,4,1)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,ProductId)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;My goal is to make a sheet, where user can see stats per selected product ID. The first expression was reworked to look like this:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;max({&amp;lt;ProductId = {Id1}&amp;gt;}&lt;/STRONG&gt; Aggr(Rank(&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;if(Count(distinct {&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},flag={1}&amp;gt;} [Counter Field])&amp;gt;=vThreshold,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Sum({&amp;lt;flag={1}&amp;gt;}Aggr(Sum({&amp;lt;Period={$(vCurrent_Period)},FieldType={'Quantity'},&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;flag={1}&amp;gt;}ValueField)*if(vType='Quantity',&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;sum({&amp;lt;flag={1}&amp;gt;}[Regional sales Weight])&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;,1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;[Counter Field],ProductId)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;),4,1),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Region,&lt;/STRONG&gt;ProductId)&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;It works fine and I can see the correct ranking per region for the selected product ID. However, if I try to rework the second expression using the same approach, it doesn't work. Do you have any ideas why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 18:27:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Ranking-with-Aggr-per-region/m-p/1880322#M72550</guid>
      <dc:creator>Primrose</dc:creator>
      <dc:date>2022-01-12T18:27:13Z</dc:date>
    </item>
  </channel>
</rss>

