<?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 Fixing a Nested Aggregation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029699#M347756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Qlik Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a piece of code for a KPI to determine '% of Items &amp;gt; Average Failure Date'.&lt;/P&gt;&lt;P&gt;In the data set, we have a list of items, which have a created date, failure date (only populated if the asset has failed), and age (difference between todays date and created date if there isn't a failed date, otherwise the difference between created and failed dates) and status ('Failure' if they have a failure date populated, otherwise 'Live').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count(if(Item_status&amp;lt;&amp;gt;'Failure' and Item_Age &amp;gt; AVG({ &amp;lt;Item_status = {"Failure"}&amp;gt;} [Item_Age]) ,Item_ID))&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;Count(if(Item_status&amp;lt;&amp;gt;'Failure' ,Item_ID)) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm getting the error: 'Error in Expression, Nested Aggregation is not allowed'.&lt;/P&gt;&lt;P&gt;The idea is in the numerator, I'm counting all assets which haven't failed whose age is beyond the average age of all failed items.&lt;/P&gt;&lt;P&gt;Then in the denominator, dividing it by the count of all non-failed assets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how I can change it to bypass the nested error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Mar 2016 15:44:24 GMT</pubDate>
    <dc:creator>andyquirin</dc:creator>
    <dc:date>2016-03-08T15:44:24Z</dc:date>
    <item>
      <title>Fixing a Nested Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029699#M347756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Qlik Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on a piece of code for a KPI to determine '% of Items &amp;gt; Average Failure Date'.&lt;/P&gt;&lt;P&gt;In the data set, we have a list of items, which have a created date, failure date (only populated if the asset has failed), and age (difference between todays date and created date if there isn't a failed date, otherwise the difference between created and failed dates) and status ('Failure' if they have a failure date populated, otherwise 'Live').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;count(if(Item_status&amp;lt;&amp;gt;'Failure' and Item_Age &amp;gt; AVG({ &amp;lt;Item_status = {"Failure"}&amp;gt;} [Item_Age]) ,Item_ID))&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;Count(if(Item_status&amp;lt;&amp;gt;'Failure' ,Item_ID)) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm getting the error: 'Error in Expression, Nested Aggregation is not allowed'.&lt;/P&gt;&lt;P&gt;The idea is in the numerator, I'm counting all assets which haven't failed whose age is beyond the average age of all failed items.&lt;/P&gt;&lt;P&gt;Then in the denominator, dividing it by the count of all non-failed assets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how I can change it to bypass the nested error?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2016 15:44:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029699#M347756</guid>
      <dc:creator>andyquirin</dc:creator>
      <dc:date>2016-03-08T15:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing a Nested Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029700#M347757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Perhaps by calculating the average outside the chart context:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;count(if(Item_status&amp;lt;&amp;gt;'Failure' and Item_Age &amp;gt; $(=AVG({ &amp;lt;Item_status = {"Failure"}&amp;gt;} [Item_Age])),Item_ID))&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;/&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Count(if(Item_status&amp;lt;&amp;gt;'Failure' ,Item_ID))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 13:15:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029700#M347757</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2016-03-10T13:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fixing a Nested Aggregation</title>
      <link>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029701#M347758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you need to provide an aggr for the avg:&lt;/P&gt;&lt;P&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;aggr(AVG({ &amp;lt;Item_status = {"Failure"}&amp;gt;} [Item_Age]) , &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Item_ID)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;-Rob&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Mar 2016 16:45:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Fixing-a-Nested-Aggregation/m-p/1029701#M347758</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2016-03-10T16:45:18Z</dc:date>
    </item>
  </channel>
</rss>

