<?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: Calculating AVG with condition in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335959#M29293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is NB_CALLS a field name or is this an expression? If this is an expression, then may be this&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Avg(Aggr(If(Sum(Calls) &amp;gt; 10, Sum(Calls)), DAY, EMPLOYEE))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Jul 2017 16:22:15 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2017-07-19T16:22:15Z</dc:date>
    <item>
      <title>Calculating AVG with condition</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335957#M29291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following (simplified) table :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); border-image: none; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;DAY&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;EMPLOYEE&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;P&gt;&lt;STRONG&gt;NB_CALLS&lt;/STRONG&gt;&lt;/P&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;19&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;02/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;John&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Jane&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;21&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;02/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Jane&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Jane&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;04/01/2017&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Jane&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The business requirement is to have an expression that calculates the average number of calls per day and employee (no problem) but with the following condition : &lt;STRONG&gt;a day must only be counted if the number of calls is strictly superior to 10&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the 2nd and 6th line of the table should be "ignored", giving us an average of :&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;(19+13)/2 = 16 for John&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;(21+15+11)/3 = 15.7 for Jane&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;Do you think that this is possible to calculate in an expression, so that the data model doesn't need to be changed ? I have made some tests with the aggr() function but I can't get the correct results...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help, don't hesitate to ask if you need more details about my issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jul 2017 13:18:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335957#M29291</guid>
      <dc:creator>fab_castanheira</dc:creator>
      <dc:date>2017-07-19T13:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating AVG with condition</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335958#M29292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you try something like this?&lt;/P&gt;&lt;P&gt;=Avg({$&amp;lt;NB_Calls-={"&amp;lt;10"}&amp;gt;}NB_Calls)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:00:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335958#M29292</guid>
      <dc:creator>wallerjc</dc:creator>
      <dc:date>2017-07-19T16:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating AVG with condition</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335959#M29293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is NB_CALLS a field name or is this an expression? If this is an expression, then may be this&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Avg(Aggr(If(Sum(Calls) &amp;gt; 10, Sum(Calls)), DAY, EMPLOYEE))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Jul 2017 16:22:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335959#M29293</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-07-19T16:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating AVG with condition</title>
      <link>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335960#M29294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Sunny for answer, the expression works fine !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2017 09:56:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculating-AVG-with-condition/m-p/1335960#M29294</guid>
      <dc:creator>fab_castanheira</dc:creator>
      <dc:date>2017-07-20T09:56:49Z</dc:date>
    </item>
  </channel>
</rss>

