<?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: Exclude double entries from calculation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684512#M248072</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a solution that uses the data that you posted above. The expression will work in a chart or text box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It calculates the avg by summing only 1 record per ID where the start date = max start date for that ID and divides by the number of IDs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum( aggr( if( Max( total &amp;lt;ID&amp;gt; [Start Date]) = [Start Date], [Days to Close]), ID, [Sales Area],[Sales Person],[Start Date],[End Date]))&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;count( DISTINCT ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/69545_Capture.PNG.png" style="width: 620px; height: 276px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 23 Oct 2014 13:47:07 GMT</pubDate>
    <dc:creator>JonnyPoole</dc:creator>
    <dc:date>2014-10-23T13:47:07Z</dc:date>
    <item>
      <title>Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684510#M248070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would very much appreciate some assistance with the exclusion of double entries from an AVG calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example below, I have three records, two of which is are related to the same sales activity. While both records are valid, I only want to count the latest record in my AVG calculation of how many days the activity took to close.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, my AVG calculation comes up with an average of 39 days to close.&lt;/P&gt;&lt;P&gt;It should only be 28.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas of a quick way of only including the latest sales activity in the calculation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 437px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="15" width="65"&gt;&lt;STRONG&gt;ID&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" width="65"&gt;&lt;STRONG&gt;Sales Area&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" width="103"&gt;&lt;STRONG&gt;Sales Person&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" width="65"&gt;&lt;STRONG&gt;Start Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" width="65"&gt;&lt;STRONG&gt;End Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl63" width="74"&gt;&lt;STRONG&gt;Days to Close&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" height="15"&gt;123&lt;/TD&gt;&lt;TD&gt;Orlando&lt;/TD&gt;&lt;TD&gt;Donald Smith&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;3/19/14&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;5/19/14&lt;/TD&gt;&lt;TD align="right" class="xl65" style="text-align: right;"&gt;61&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl66" height="15"&gt;&lt;SPAN style="color: #ff0000;"&gt;234&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="color: #ff0000;"&gt;Los Angeles&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="color: #ff0000;"&gt;Jan Anderson&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;&lt;SPAN style="color: #ff0000;"&gt;4/4/14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;&lt;SPAN style="color: #ff0000;"&gt;4/30/14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl68" style="text-align: right;"&gt;&lt;SPAN style="color: #ff0000;"&gt;26&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD align="right" class="xl66" height="15"&gt;&lt;SPAN style="color: #ff0000;"&gt;123&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="color: #ff0000;"&gt;Orlando&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD class="xl66"&gt;&lt;SPAN style="color: #ff0000;"&gt;Donald Smith&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;&lt;SPAN style="color: #ff0000;"&gt;4/19/14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl67"&gt;&lt;SPAN style="color: #ff0000;"&gt;5/19/14&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl68" style="text-align: right;"&gt;&lt;SPAN style="color: #ff0000;"&gt;30&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Avg&lt;/TD&gt;&lt;TD align="right" class="xl65"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD style="text-align: right;"&gt;39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" colspan="2"&gt;&lt;SPAN style="color: #ff0000;"&gt;Avg (without first ID)&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD align="right" class="xl68"&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD style="text-align: right;"&gt;&lt;SPAN style="color: #ff0000;"&gt;28&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:32:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684510#M248070</guid>
      <dc:creator>klaus_feldam</dc:creator>
      <dc:date>2014-10-23T13:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684511#M248071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the source of this data?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This can be done in SQL (If thats where it comes from) with a window function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Rank() Over(Partition by ID, [Sales Area] Order by [Start Date] desc, [End Date] as RecordOrder&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, in your application you could add {$&amp;lt;RecordOrder={1}&amp;gt;} to your expressions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure how best to do this at the application level.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:38:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684511#M248071</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-10-23T13:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684512#M248072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a solution that uses the data that you posted above. The expression will work in a chart or text box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It calculates the avg by summing only 1 record per ID where the start date = max start date for that ID and divides by the number of IDs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum( aggr( if( Max( total &amp;lt;ID&amp;gt; [Start Date]) = [Start Date], [Days to Close]), ID, [Sales Area],[Sales Person],[Start Date],[End Date]))&lt;/P&gt;&lt;P&gt;/&lt;/P&gt;&lt;P&gt;count( DISTINCT ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.PNG.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/69545_Capture.PNG.png" style="width: 620px; height: 276px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:47:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684512#M248072</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-10-23T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684513#M248073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would do the following in the script&lt;/P&gt;&lt;P&gt;I first sort data by ID and date desc&lt;/P&gt;&lt;P&gt;and then I reload again saying:&lt;/P&gt;&lt;P&gt;if(RowNO() = 1 or ID &amp;lt;&amp;gt; previous(ID), 1,peek(rank)+1) as rank&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then in the expression I would write sum({&amp;lt;rank={1}&amp;gt;} days_to_close)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 13:47:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684513#M248073</guid>
      <dc:creator>ali_hijazi</dc:creator>
      <dc:date>2014-10-23T13:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684514#M248074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Jonathan.&lt;/P&gt;&lt;P&gt;Extremely helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question:&lt;/P&gt;&lt;P&gt;[Days to Close] is a calculation of [Start Date] - [End Date]. I wonder how a revised would formula look.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like this?&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;=sum( aggr( if( Max( total &amp;lt;ID&amp;gt; [Start Date]) = [Start Date], ([Start Date] - [End Date])), ID, [Sales Area],[Sales Person],[Start Date],[End Date]))&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;/&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;count( DISTINCT ID)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 17:20:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684514#M248074</guid>
      <dc:creator>klaus_feldam</dc:creator>
      <dc:date>2014-10-23T17:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684515#M248075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That should work too.&amp;nbsp; You could also use the INTERVAL function to format the interval in Days, hours, minutes etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did it work ? &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 18:17:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684515#M248075</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-10-23T18:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude double entries from calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684516#M248076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it worked well. &lt;/P&gt;&lt;P&gt;Thank you very much, Jonathan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Oct 2014 22:16:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Exclude-double-entries-from-calculation/m-p/684516#M248076</guid>
      <dc:creator>klaus_feldam</dc:creator>
      <dc:date>2014-10-23T22:16:09Z</dc:date>
    </item>
  </channel>
</rss>

