<?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: Conditional aggregation based on records before selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Conditional-aggregation-based-on-records-before-selection/m-p/572603#M213325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I have solved the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to use two aggr(-statements to allow the test to perform correct and then the data to show like i wanted: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Expression is like following&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Type&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;={1}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;NoDistinct&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;[$(=Concat({1&amp;lt;$Table={'Calendar'}&amp;gt;} distinct $Field,']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;=,&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;[')&amp;amp;']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;='), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;={"&amp;lt;$(=&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;min&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;))"}&amp;gt;} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Total&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;), &lt;SPAN style="color: #800000; font-family: Arial, sans-serif; font-size: 12px;"&gt;Customer&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;))=0, &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;)), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;, &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Type&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;=1}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;NoDistinct&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: gray;"&gt;$(PrevDays)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Total&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;), &lt;SPAN style="color: #800000; font-family: Arial, sans-serif; font-size: 12px;"&gt;Customer&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;))=0, &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;)), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;, &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where &lt;STRONG style="color: #000000; font-family: Arial, sans-serif; font-size: 12px;"&gt;&lt;EM&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: gray;"&gt;$(PrevDays)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt; = &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;{$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;[$(=Concat({1&amp;lt;$Table={'Calendar'}&amp;gt;} distinct $Field,']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;=,&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;[')&amp;amp;']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;='), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;={"&amp;lt;$(=&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;min&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;))"}&amp;gt;} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope other can find use of this case in future &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Feb 2014 15:47:27 GMT</pubDate>
    <dc:creator>martinpedersen</dc:creator>
    <dc:date>2014-02-26T15:47:27Z</dc:date>
    <item>
      <title>Conditional aggregation based on records before selection</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-aggregation-based-on-records-before-selection/m-p/572602#M213324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Short Story:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have some problems regarding the understanding the aggregation formula, in a case where I need to test if a customer has made any purchases before the selection; so I can divide sales in "new customers" and "Old Customers". If a customer make several purchases in the selected period; all the purchases should be counted as "New Customer"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setting of issue:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I need to make this pivot that splits sales data by day based on the users date selections (From multiple "unknown" date fields in a Calendar Table);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.g. Year, Month, Day, Week, Financial Year, YTD, WTD and so on. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date:&lt;/P&gt;&lt;P&gt;20140101: 100&lt;/P&gt;&lt;P&gt;20140102: 75&lt;/P&gt;&lt;P&gt;20140103: 150&lt;/P&gt;&lt;P&gt;20140104: 25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dimension: Date.&lt;/P&gt;&lt;P&gt;Expression: Sum(Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far so good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Issue:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My problem is to split the Sales Data into "new" and "old" customers based on customers, has made any purchases before the first selected date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to make a Set Analysis that ignores all date Selections and inverts the selection to all days before the selections:&lt;/P&gt;&lt;P&gt;{1&amp;lt;[$(=Concat({1&amp;lt;$Table={'Calendar'}&amp;gt;} distinct $Field,']=,[')&amp;amp;']='), Date={"&amp;lt;$(=min(Date))"}&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have put this set analysis in a variable called $(PrevDays) and my expression looks something like this:&lt;/P&gt;&lt;P&gt;Sum({$&amp;lt;MemberGroup={1}, aggr(If(Sum($(vPrevDays) Sales)&amp;gt;0, Sum(Sales)), Member))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It does the test for previous purchases in the total; but puts all the following transaction in a day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Eg. 2 customers had made a purchase in 2013:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Customer 1 has made these sales in 2014:&lt;/P&gt;&lt;P&gt;20140101: 25&lt;/P&gt;&lt;P&gt;20140102: 0&lt;/P&gt;&lt;P&gt;20140103: 0&lt;/P&gt;&lt;P&gt;20140104: 20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And Customer 2 has made these sales in 2014:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20140101: 0&lt;/P&gt;&lt;P&gt;20140102: 10&lt;/P&gt;&lt;P&gt;20140103: 0&lt;/P&gt;&lt;P&gt;20140104: 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My chart now shows the following:&lt;/P&gt;&lt;P&gt;20140101: 45&lt;/P&gt;&lt;P&gt;20140102: 10&lt;/P&gt;&lt;P&gt;20140103: 0&lt;/P&gt;&lt;P&gt;20140104: 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where I would like it to show something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Old Customers:&lt;/P&gt;&lt;P&gt;20140101: 25&lt;/P&gt;&lt;P&gt;20140102: 10&lt;/P&gt;&lt;P&gt;20140103: 0&lt;/P&gt;&lt;P&gt;20140104: 25&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;New Customers:&lt;/P&gt;&lt;P&gt;20140101: 75&lt;/P&gt;&lt;P&gt;20140102: 60&lt;/P&gt;&lt;P&gt;20140103: 150&lt;/P&gt;&lt;P&gt;20140104: 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ps. If I use the "Aggr(NoDistinct" i gets this:&lt;/P&gt;&lt;P&gt;Old Customers&lt;/P&gt;&lt;P&gt;20140101: 45&lt;/P&gt;&lt;P&gt;20140102: 10&lt;/P&gt;&lt;P&gt;20140103: 0&lt;/P&gt;&lt;P&gt;20140104: 45&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope someone would share their thoughts with me on this one - and please let me know if i need to explain more of the details.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 14:32:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-aggregation-based-on-records-before-selection/m-p/572602#M213324</guid>
      <dc:creator>martinpedersen</dc:creator>
      <dc:date>2014-02-26T14:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional aggregation based on records before selection</title>
      <link>https://community.qlik.com/t5/QlikView/Conditional-aggregation-based-on-records-before-selection/m-p/572603#M213325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I have solved the issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I needed to use two aggr(-statements to allow the test to perform correct and then the data to show like i wanted: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Expression is like following&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Type&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;={1}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;NoDistinct&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;[$(=Concat({1&amp;lt;$Table={'Calendar'}&amp;gt;} distinct $Field,']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;=,&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;[')&amp;amp;']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;='), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;={"&amp;lt;$(=&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;min&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;))"}&amp;gt;} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: blue;"&gt;Total&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;), &lt;SPAN style="color: #800000; font-family: Arial, sans-serif; font-size: 12px;"&gt;Customer&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;))=0, &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;)), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;, &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: maroon;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Or &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Type&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;=1}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;NoDistinct&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: gray;"&gt;$(PrevDays)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;Total&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;), &lt;SPAN style="color: #800000; font-family: Arial, sans-serif; font-size: 12px;"&gt;Customer&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;))=0, &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 9pt; font-family: Arial, sans-serif;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Sales&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;)), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;, &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Customer&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where &lt;STRONG style="color: #000000; font-family: Arial, sans-serif; font-size: 12px;"&gt;&lt;EM&gt;&lt;SPAN lang="EN-US" style="font-size: 9.0pt; font-family: 'Arial','sans-serif'; color: gray;"&gt;$(PrevDays)&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt; = &lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;{$&amp;lt;&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;[$(=Concat({1&amp;lt;$Table={'Calendar'}&amp;gt;} distinct $Field,']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;=,&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;[')&amp;amp;']&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;='), &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;={"&amp;lt;$(=&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue;"&gt;min&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: maroon;"&gt;Date&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: black;"&gt;))"}&amp;gt;} &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope other can find use of this case in future &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 15:47:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Conditional-aggregation-based-on-records-before-selection/m-p/572603#M213325</guid>
      <dc:creator>martinpedersen</dc:creator>
      <dc:date>2014-02-26T15:47:27Z</dc:date>
    </item>
  </channel>
</rss>

