<?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: Script Variable Usage in SQL Where Clause in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837554#M1002179</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;Just try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;LET Start_Key_Inc = chr(39) &amp;amp; Max(OND_KEY) &amp;amp; chr(39);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;or &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; background-color: #f2f2f2; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;LET Start_Key_Inc = &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt; chr(39) &amp;amp;&lt;/SPAN&gt; Peek('Max', 0, 'MAX') &amp;amp; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt; chr(39)&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joaquín&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jun 2015 14:34:47 GMT</pubDate>
    <dc:creator>Joaquin_Lazaro</dc:creator>
    <dc:date>2015-06-05T14:34:47Z</dc:date>
    <item>
      <title>Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837550#M1002175</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 try to make an incremental load work by first loading the current data into &lt;SPAN style="font-size: 13.3333330154419px;"&gt;FAC_OND_DELEN_X from qvd and then determine the latest record and store that into a variable Start_Key. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The I load the new records from the DB2 database except the variable Start_Key in the Where Clause doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Who can help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FAC_OND_DELEN_X:&lt;/P&gt;&lt;P&gt;LOAD*&lt;/P&gt;&lt;P&gt;FROM $(PAD)FAC_OND_DELEN_INC.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET Start_Key_Inc = Max(OND_KEY);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concatenate&lt;/P&gt;&lt;P&gt;FAC_OND_DELEN_NEW:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;LOAD *;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SQL SELECT *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;FROM DWH.FAC_OND_DELEN&lt;/P&gt;&lt;P&gt;Where OND_ST In(1,6,7) And OND_NR_LEVERING &amp;lt;&amp;gt; 0 And &lt;SPAN style="color: #ff0000;"&gt;OND_KEY &amp;gt; $(Start_Key_Inc);&lt;/SPAN&gt;&amp;nbsp; // Also Tried '$(Start_Key_Inc)'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:05:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837550#M1002175</guid>
      <dc:creator />
      <dc:date>2015-06-05T14:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837551#M1002176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you need to use the Max() function within a LOAD statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FAC_OND_DELEN_X:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD *&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM $(PAD)FAC_OND_DELEN_INC.qvd (qvd);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;MAX:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Max(OND_KEY) as Max&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;RESIDENT FAC_OND_DELEN_X;&lt;/SPAN&gt; &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LET Start_Key_Inc = Peek('Max', 0, 'MAX');&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;DROP TABLE MAX;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Concatenate&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FAC_OND_DELEN_NEW:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;LOAD *;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;SQL SELECT *&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM DWH.FAC_OND_DELEN&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Where OND_ST In(1,6,7) And OND_NR_LEVERING &amp;lt;&amp;gt; 0 And &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #ff0000;"&gt;OND_KEY &amp;gt; $(Start_Key_Inc);&lt;/SPAN&gt;&amp;nbsp; // Also Tried '$(Start_Key_Inc)'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:11:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837551#M1002176</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2015-06-05T14:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837552#M1002177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;SPAN style="font-size: 11.6999998092651px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG&gt;&lt;A href="https://community.qlik.com/people/Mvdvosse"&gt;Mvdvosse&lt;/A&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vEscheme = 'PROD';&lt;/P&gt;&lt;P&gt;LET vVariable = 'CompanyA'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; FROM $(vEscheme).Table&lt;/P&gt;&lt;P&gt;&amp;nbsp; WHERE FIELD1 = $(vVariable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND DATE &amp;gt;= '2013/01/01';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you&lt;/P&gt;&lt;P&gt;Joaquín&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:12:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837552#M1002177</guid>
      <dc:creator>Joaquin_Lazaro</dc:creator>
      <dc:date>2015-06-05T14:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837553#M1002178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't realy see the difference. The variable has the right value. It is just that the database doesn't recognize the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx for suggesting though.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:23:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837553#M1002178</guid>
      <dc:creator />
      <dc:date>2015-06-05T14:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837554#M1002179</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;Just try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;LET Start_Key_Inc = chr(39) &amp;amp; Max(OND_KEY) &amp;amp; chr(39);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;or &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; background-color: #f2f2f2; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;LET Start_Key_Inc = &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt; chr(39) &amp;amp;&lt;/SPAN&gt; Peek('Max', 0, 'MAX') &amp;amp; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt; chr(39)&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Joaquín&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:34:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837554#M1002179</guid>
      <dc:creator>Joaquin_Lazaro</dc:creator>
      <dc:date>2015-06-05T14:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837555#M1002180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Michel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the variable expansion should happen before the SQL code is sent to the DB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you run the code in debug mode of the script editor, what is shown as expanded code?&lt;/P&gt;&lt;P&gt;What do you expect to see?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:45:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837555#M1002180</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2015-06-05T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837556#M1002181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a guess: maybe because OND_KEY contains non-numeric values? Meaning that you cannot compare them using a greater than operator?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is also something wrong with your CONCATENATE LOAD syntax. The table name should either be eliminated (you're not creating a new table, you're just adding records to a table that already exists) or replaced by a table name to which you want to concatenate the new data, e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;CONCATENATE (&lt;SPAN style="color: #3d3d3d; font-size: 13px;"&gt;FAC_OND_DELEN_X)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'courier new', courier;"&gt;LOAD ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:50:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837556#M1002181</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-06-05T14:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837557#M1002182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or if you create a log file during script execution, you will get an expanded SELECT statement as well. Does it match your expectations?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 14:59:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837557#M1002182</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-06-05T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837558#M1002183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think we can&amp;nbsp; assume a numeric variable value because of the max() function usage.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:05:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837558#M1002183</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2015-06-05T15:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837559#M1002184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, I learned to never trust data quality on rumours alone... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; A simple confirmation would lay that one to rest. Let's call it "deduction by elimination".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That LET statement shouldn't work. Like you said, Max() must be used in a LOAD statement. That makes the situation a lot more awkward...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jun 2015 15:21:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837559#M1002184</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-06-05T15:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script Variable Usage in SQL Where Clause</title>
      <link>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837560#M1002185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swuehl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have put The Max function in a load statement and combined that with a peek function. After matching the notation of the date and adding the '' in the where clause it works like clockwork. Thanx!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FAC_OND_DELEN_X:&lt;/P&gt;&lt;P&gt;LOAD*&lt;/P&gt;&lt;P&gt;FROM $(PAD)FAC_OND_DELEN_INC.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MAXKEY:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Date(Max(OND_PER)-1, 'DD/MM/YYYY') AS MAXDATE&lt;/P&gt;&lt;P&gt;Resident&amp;nbsp; FAC_OND_DELEN_X;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET Start_Key_Inc = Date(Peek('MAXDATE',0), 'DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table MAXKEY;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concatenate&lt;/P&gt;&lt;P&gt;FAC_OND_DELEN_NEW:&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OND_YEAR &amp;amp; '_' &amp;amp; OND_OGM AS OND_YEAR_OG;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Year(OND_PER) AS OND_YEAR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If(Year(OND_PER) = 2015 AND OND_OG = 39, 13, OND_OG) AS OND_OGM;&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;/P&gt;&lt;P&gt;FROM DWH.FAC_OND_DELEN&lt;/P&gt;&lt;P&gt;Where OND_ST In(1,6,7) And OND_NR_LEVERING &amp;lt;&amp;gt; 0 And OND_PER &amp;gt; '$(Start_Key_Inc)';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jun 2015 14:42:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Script-Variable-Usage-in-SQL-Where-Clause/m-p/837560#M1002185</guid>
      <dc:creator />
      <dc:date>2015-06-08T14:42:09Z</dc:date>
    </item>
  </channel>
</rss>

