<?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 Help with strange result using the AGGR function? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218473#M500610</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Typically you would want to do an aggr(if( and not an if(aggr(. It is helpful to think of an aggr as creating a straight table in memory, where the expression is your first parameter and the dimensions are your 2+ parameters. So, change your first expression to this:&lt;/P&gt;&lt;P&gt;sum(aggr(nodistinct if(sum(SpellCost)&amp;gt;=MaxCost,1,0),Patientid))&lt;/P&gt;&lt;P&gt;Change your last pivot table expression to this: if(sum(SpellCost)&amp;gt;=MaxCost,text('Yes'),text('No'))&lt;/P&gt;&lt;P&gt;Hopefully that will match up, but let me know if it still doesn't work.&lt;BR /&gt;Cheers,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Feb 2011 01:50:35 GMT</pubDate>
    <dc:creator>vgutkovsky</dc:creator>
    <dc:date>2011-02-17T01:50:35Z</dc:date>
    <item>
      <title>Help with strange result using the AGGR function?</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218472#M500609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to count how many patients have a total hospital spell cost greater that a certain amount. When I use the following calculation I always get an answer which is 1 higher than expected! Does anyone know why and also how to fix the problem?&lt;/P&gt;&lt;P&gt;Example: Max Cost = 50,000&lt;/P&gt;&lt;P&gt;In a text box (whilst testing the calc out) I have =sum(if(aggr(sum(SpellCost),Patientid)&amp;gt;=MaxCost,1,0))&lt;/P&gt;&lt;P&gt;I also have a pivot table showing 'patientid', 'sum(spellcost)', Yes/No coming from the calc &lt;B&gt;if&lt;/B&gt;(&lt;B&gt;aggr&lt;/B&gt;(&lt;B&gt;sum&lt;/B&gt;(&lt;B&gt;SpellCost&lt;/B&gt;),Patientid)&amp;gt;=&lt;B&gt;MaxCost&lt;/B&gt;,'Yes','No')&lt;/P&gt;&lt;P&gt;The pivot table shows me 5 different patients who have a total cost &amp;gt;=50000 but the text box comes back with the answer 6 ??&lt;/P&gt;&lt;P&gt;Any ideas why this is happening?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sandra Thompson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Feb 2011 14:25:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218472#M500609</guid>
      <dc:creator />
      <dc:date>2011-02-16T14:25:24Z</dc:date>
    </item>
    <item>
      <title>Help with strange result using the AGGR function?</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218473#M500610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Typically you would want to do an aggr(if( and not an if(aggr(. It is helpful to think of an aggr as creating a straight table in memory, where the expression is your first parameter and the dimensions are your 2+ parameters. So, change your first expression to this:&lt;/P&gt;&lt;P&gt;sum(aggr(nodistinct if(sum(SpellCost)&amp;gt;=MaxCost,1,0),Patientid))&lt;/P&gt;&lt;P&gt;Change your last pivot table expression to this: if(sum(SpellCost)&amp;gt;=MaxCost,text('Yes'),text('No'))&lt;/P&gt;&lt;P&gt;Hopefully that will match up, but let me know if it still doesn't work.&lt;BR /&gt;Cheers,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 01:50:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218473#M500610</guid>
      <dc:creator>vgutkovsky</dc:creator>
      <dc:date>2011-02-17T01:50:35Z</dc:date>
    </item>
    <item>
      <title>Help with strange result using the AGGR function?</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218474#M500611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The piviot table expression givesthe same results as I had,which is fine. But the first expression still gives one more than expected (after I took 'nodistinct' out - this gave me hundreds more which may be something to do with blank patientids?)&lt;/P&gt;&lt;P&gt;If I put 'distinct' into my original first expression it gives the correct number but I don't know why, so am not really happy about just putting it in. Also, if I choose a month in one of the pages selection box,es, it goes back to giving 1 more than the answer?!&lt;/P&gt;&lt;P&gt;I may have to give up and just use the pivot table. (I was going to use the first expression in a graph to show the number of high cost patients by GP practice)&lt;/P&gt;&lt;P&gt;Thanks for helping!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 10:03:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-strange-result-using-the-AGGR-function/m-p/218474#M500611</guid>
      <dc:creator />
      <dc:date>2011-02-17T10:03:47Z</dc:date>
    </item>
  </channel>
</rss>

