<?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: Where clause with max date in load script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819335#M665444</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TMP:&lt;/P&gt;&lt;P&gt;LOAD min(&lt;STRONG&gt;[Week Start Date]) as mini, max(&lt;/STRONG&gt;&lt;STRONG&gt;[Week Start Date]) as maxi &lt;/STRONG&gt;esident [SKU Segmentation];&lt;/P&gt;&lt;P&gt;Let vMin = peek('mini',0,'TMP');&lt;/P&gt;&lt;P&gt;Let vMax = peek('maxi',0,'TMP');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TMP;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now in your query write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where [Week Start Date] &amp;gt;= $(&lt;/STRONG&gt;vMin &lt;STRONG&gt;) AND [Week Start Date] &amp;lt;= $(vMax);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let me know&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jan 2015 12:45:03 GMT</pubDate>
    <dc:creator>alexandros17</dc:creator>
    <dc:date>2015-01-20T12:45:03Z</dc:date>
    <item>
      <title>Where clause with max date in load script</title>
      <link>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819334#M665442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am loading in a table of product and volume information, then want to restrict this table by a date range. I have initially used static dates in my WHERE clause but now want to make these dynamic. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following script works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[SKU Segmentation]:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; [SKU Number] as %SKU,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum([Actual Volume (HL) W+1]) as SKUVolume,&lt;/P&gt;&lt;P&gt;&amp;nbsp; [Week Start Date]&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[AnalyticsData.xlsm]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is [Demand - W+1])&lt;/P&gt;&lt;P&gt;WHERE [Actual Volume (HL) W+1] &amp;gt;='0' AND ([Actual Volume (HL) W+1] &amp;lt;&amp;gt; '0' OR [Forecasted Volume (HL) W+1] &amp;lt;&amp;gt; '0')&lt;/P&gt;&lt;P&gt;group by [SKU Number], [Week Start Date]&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[SKU Seg 2]:&lt;/P&gt;&lt;P&gt;LOAD %SKU,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(SKUVolume) as SKUVolume2&lt;/P&gt;&lt;P&gt;resident [SKU Segmentation]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where [Week Start Date] &amp;gt;= '01/01/2013' AND [Week Start Date] &amp;lt;= '01/01/2014'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;group by %SKU;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table [SKU Segmentation];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to change the bolded WHERE statement above so that my minimum and maximum dates are as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;min: = date(max([Week Start Date])-365)&lt;/P&gt;&lt;P&gt;max: = date(max([Week Start Date]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would think the WHERE clause would then be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where [Week Start Date] &amp;gt;= date(max([Week Start Date])-365) AND [Week Start Date] &amp;lt;= date(max([Week Start Date]))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't seem to work when I load however, are there any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2015 12:39:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819334#M665442</guid>
      <dc:creator />
      <dc:date>2015-01-20T12:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause with max date in load script</title>
      <link>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819335#M665444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TMP:&lt;/P&gt;&lt;P&gt;LOAD min(&lt;STRONG&gt;[Week Start Date]) as mini, max(&lt;/STRONG&gt;&lt;STRONG&gt;[Week Start Date]) as maxi &lt;/STRONG&gt;esident [SKU Segmentation];&lt;/P&gt;&lt;P&gt;Let vMin = peek('mini',0,'TMP');&lt;/P&gt;&lt;P&gt;Let vMax = peek('maxi',0,'TMP');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table TMP;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now in your query write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where [Week Start Date] &amp;gt;= $(&lt;/STRONG&gt;vMin &lt;STRONG&gt;) AND [Week Start Date] &amp;lt;= $(vMax);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;let me know&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2015 12:45:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819335#M665444</guid>
      <dc:creator>alexandros17</dc:creator>
      <dc:date>2015-01-20T12:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause with max date in load script</title>
      <link>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819336#M665446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fantastic, thanks so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2015 12:54:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-clause-with-max-date-in-load-script/m-p/819336#M665446</guid>
      <dc:creator />
      <dc:date>2015-01-20T12:54:12Z</dc:date>
    </item>
  </channel>
</rss>

