<?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: Fractile() - Function not working in set analysis in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Fractile-Function-not-working-in-set-analysis/m-p/1801849#M65032</link>
    <description>&lt;P&gt;The set analysis syntax isn't quite right and should be look more like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
	${
    	&amp;lt;
        seconds = {"&amp;gt;=$(=Fractile(seconds, 0.99))"}
        &amp;gt;
    }
    user_id
)&lt;/LI-CODE&gt;&lt;P&gt;whereby the now per $-sign expansion created adhoc-variable is calculated globally before the chart the calculated and applied to each row - means you couldn't use such logic if it needs to consider the dimensionality of your object. But because of your applied TOTAL within the if-loop which ignores all dimensionality it may be suitable for your use-case.&lt;/P&gt;&lt;P&gt;If not you may change it to something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
	${
    	&amp;lt;
        user_id = {"=seconds&amp;gt;=Fractile(TOTAL seconds, 0.99)"}
        &amp;gt;
    }
    user_id
)&lt;/LI-CODE&gt;&lt;P&gt;which forced an evaluation on row-level but technically it's quite the same like as an if-loop and therefore it shouldn't be a big difference in regard to the performance - whereby I didn't measured it directly against each other.&lt;/P&gt;&lt;P&gt;Beside this your here shown expression for the if-loop didn't look right respectively completed because it's a nested aggregation which isn't allowed without using an aggr(). But you may change it to:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(seconds &amp;gt;= Fractile(TOTAL seconds, 0.99), Count(user_id))&lt;/LI-CODE&gt;&lt;P&gt;which could avoid the nesting aggregation and the logic:&lt;/P&gt;&lt;P&gt;if(condition, sum/count(field))&lt;/P&gt;&lt;P&gt;is in general much more performant as:&lt;/P&gt;&lt;P&gt;sum/count(if(condition, field))&lt;/P&gt;&lt;P&gt;If all those approaches didn't work or are further too slow you will need to look to optimize your datamodel to ensure that all relevant fields comes from a single table.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 15:21:39 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2021-04-22T15:21:39Z</dc:date>
    <item>
      <title>Fractile() - Function not working in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Fractile-Function-not-working-in-set-analysis/m-p/1801623#M65003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i am having an issue in using fractile-function in set analysis. The following statement including set analysis is resulting in 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
	${
    	&amp;lt;
        seconds = {"(&amp;gt;=Fractile(seconds, 0.99))"}
        &amp;gt;
    }
    user_id
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whereas the following statement is working, but is really really slow:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
    if
    (
        seconds &amp;gt;= Fractile(TOTAL seconds, 0.99)
	, user_id
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to fix this?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 07:39:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fractile-Function-not-working-in-set-analysis/m-p/1801623#M65003</guid>
      <dc:creator>TinaHensel</dc:creator>
      <dc:date>2021-04-22T07:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Fractile() - Function not working in set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Fractile-Function-not-working-in-set-analysis/m-p/1801849#M65032</link>
      <description>&lt;P&gt;The set analysis syntax isn't quite right and should be look more like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
	${
    	&amp;lt;
        seconds = {"&amp;gt;=$(=Fractile(seconds, 0.99))"}
        &amp;gt;
    }
    user_id
)&lt;/LI-CODE&gt;&lt;P&gt;whereby the now per $-sign expansion created adhoc-variable is calculated globally before the chart the calculated and applied to each row - means you couldn't use such logic if it needs to consider the dimensionality of your object. But because of your applied TOTAL within the if-loop which ignores all dimensionality it may be suitable for your use-case.&lt;/P&gt;&lt;P&gt;If not you may change it to something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count
(   
	${
    	&amp;lt;
        user_id = {"=seconds&amp;gt;=Fractile(TOTAL seconds, 0.99)"}
        &amp;gt;
    }
    user_id
)&lt;/LI-CODE&gt;&lt;P&gt;which forced an evaluation on row-level but technically it's quite the same like as an if-loop and therefore it shouldn't be a big difference in regard to the performance - whereby I didn't measured it directly against each other.&lt;/P&gt;&lt;P&gt;Beside this your here shown expression for the if-loop didn't look right respectively completed because it's a nested aggregation which isn't allowed without using an aggr(). But you may change it to:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(seconds &amp;gt;= Fractile(TOTAL seconds, 0.99), Count(user_id))&lt;/LI-CODE&gt;&lt;P&gt;which could avoid the nesting aggregation and the logic:&lt;/P&gt;&lt;P&gt;if(condition, sum/count(field))&lt;/P&gt;&lt;P&gt;is in general much more performant as:&lt;/P&gt;&lt;P&gt;sum/count(if(condition, field))&lt;/P&gt;&lt;P&gt;If all those approaches didn't work or are further too slow you will need to look to optimize your datamodel to ensure that all relevant fields comes from a single table.&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 15:21:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Fractile-Function-not-working-in-set-analysis/m-p/1801849#M65032</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2021-04-22T15:21:39Z</dc:date>
    </item>
  </channel>
</rss>

