<?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 Rank function behaving weird in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Rank-function-behaving-weird/m-p/1628412#M46747</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Let me give some context first: In my dataset, there is a natural hierarchy between Level1,Level2 &amp;amp; Level3 dimensions.&lt;/P&gt;&lt;P&gt;What I try to do is develop a bar chart with on the one hand a variable filter to let the user choose the dimension used. Also, I provide an input box to select the top N of the dimension based on occurence in my dataset.&lt;/P&gt;&lt;P&gt;Previously, in another app, i've successfully used the RANK function to do so. Now, with this extra complexity on dimension level, I've written following expression:&lt;/P&gt;&lt;P&gt;=if('$(vCWCGranularity)'='Level1',&lt;BR /&gt;aggr(&lt;BR /&gt;if(&lt;BR /&gt;rank(&lt;BR /&gt;Count($(vNPSResponses)distinct DWH_CONTACT_EVENT_ID),4,1&lt;BR /&gt;)&lt;BR /&gt;&amp;lt;=vCWCTop,REASON_LEVEL_1)&lt;BR /&gt;,REASON_LEVEL_1),&lt;BR /&gt;if('$(vCWCGranularity)'='Level2',&lt;BR /&gt;(aggr(&lt;BR /&gt;if(&lt;BR /&gt;rank(&lt;BR /&gt;Count($(vNPSResponses)distinct DWH_CONTACT_EVENT_ID),4,1&lt;BR /&gt;)&lt;BR /&gt;&amp;lt;=vCWCTop,REASON_LEVEL_2)&lt;BR /&gt;,REASON_LEVEL_2&lt;BR /&gt;)), 100))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So based on the variable vCWCGranularity, the RNAK calculation is perfomed on a different dimension. vCWCTop defines the number of points to be shown(user input). vNPSResponses is to calculate everything over a chosen time period (this works).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I execute this, I get weird results. The correct dimensions are displayed( for example the top 3), but with completely wrong values. When I leave out the vCWCGranularity logic and just calculate it over level1, it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is this a known bug, or is there something wrong with my logic?&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 04:33:50 GMT</pubDate>
    <dc:creator>robindc</dc:creator>
    <dc:date>2024-11-16T04:33:50Z</dc:date>
    <item>
      <title>Rank function behaving weird</title>
      <link>https://community.qlik.com/t5/App-Development/Rank-function-behaving-weird/m-p/1628412#M46747</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;Let me give some context first: In my dataset, there is a natural hierarchy between Level1,Level2 &amp;amp; Level3 dimensions.&lt;/P&gt;&lt;P&gt;What I try to do is develop a bar chart with on the one hand a variable filter to let the user choose the dimension used. Also, I provide an input box to select the top N of the dimension based on occurence in my dataset.&lt;/P&gt;&lt;P&gt;Previously, in another app, i've successfully used the RANK function to do so. Now, with this extra complexity on dimension level, I've written following expression:&lt;/P&gt;&lt;P&gt;=if('$(vCWCGranularity)'='Level1',&lt;BR /&gt;aggr(&lt;BR /&gt;if(&lt;BR /&gt;rank(&lt;BR /&gt;Count($(vNPSResponses)distinct DWH_CONTACT_EVENT_ID),4,1&lt;BR /&gt;)&lt;BR /&gt;&amp;lt;=vCWCTop,REASON_LEVEL_1)&lt;BR /&gt;,REASON_LEVEL_1),&lt;BR /&gt;if('$(vCWCGranularity)'='Level2',&lt;BR /&gt;(aggr(&lt;BR /&gt;if(&lt;BR /&gt;rank(&lt;BR /&gt;Count($(vNPSResponses)distinct DWH_CONTACT_EVENT_ID),4,1&lt;BR /&gt;)&lt;BR /&gt;&amp;lt;=vCWCTop,REASON_LEVEL_2)&lt;BR /&gt;,REASON_LEVEL_2&lt;BR /&gt;)), 100))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So based on the variable vCWCGranularity, the RNAK calculation is perfomed on a different dimension. vCWCTop defines the number of points to be shown(user input). vNPSResponses is to calculate everything over a chosen time period (this works).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I execute this, I get weird results. The correct dimensions are displayed( for example the top 3), but with completely wrong values. When I leave out the vCWCGranularity logic and just calculate it over level1, it works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is this a known bug, or is there something wrong with my logic?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:33:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Rank-function-behaving-weird/m-p/1628412#M46747</guid>
      <dc:creator>robindc</dc:creator>
      <dc:date>2024-11-16T04:33:50Z</dc:date>
    </item>
    <item>
      <title>Re: Rank function behaving weird</title>
      <link>https://community.qlik.com/t5/App-Development/Rank-function-behaving-weird/m-p/1628549#M46766</link>
      <description>&lt;P&gt;Your aggr() might not contain all needed dimensions, for example some period fields or any other category in which context the calculation should be happens.&lt;/P&gt;&lt;P&gt;Beside this it would be helpful (in regard of the readability of the expression and the UI performance) to use only one aggr() and to transfer the select-logic to this place. This could be done if the variable-value is identically to the used fieldnames und could be look like:&lt;/P&gt;&lt;P&gt;aggr(&lt;BR /&gt;if(rank(Count($(vNPSResponses)distinct DWH_CONTACT_EVENT_ID),4,1) &amp;lt;=vCWCTop,&lt;BR /&gt;$(vCWCGranularity))&lt;BR /&gt;,$(vCWCGranularity))&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2019 11:48:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Rank-function-behaving-weird/m-p/1628549#M46766</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2019-09-26T11:48:42Z</dc:date>
    </item>
  </channel>
</rss>

