<?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: Using a variable within SQL select statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499229#M686234</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick , I am suspecting, the problem with variable conversion into your date field datatype and syntax will change based on the DB Type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the DB is SQL Server ,&amp;nbsp; you don't to convert the variable into date format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE DATE_FIELD &amp;gt;= '$(vMaxDate)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the DB is Oracle, the syntax will depend on the DATE_FIELD data type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. If the DATE_FEILD data type is DATE then,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vMaxDate = Date(Peek('MAX_DATE') , 'YYYY-MM-DD') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT * FROM TABLE WHERE DATE_FIELD &amp;gt;= TO_DATE('$(vMaxDate)' , 'YYYY-MM-DD') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. If the DATE_FEILD data type is TIMESTAMP then,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vMaxDate = Date(Peek('MAX_DATE') , 'YYYY-MM-DD hh:mm:ss') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT * FROM TABLE WHERE DATE_FIELD &amp;gt;= TO_DATE('$(vMaxDate)' , 'YYYY-MM-DD HH24:MM:SS') ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: First test your SQL Where cond query outside qlikview like TOAD or any tool then use in Qlikview.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jan 2014 15:32:48 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-01-13T15:32:48Z</dc:date>
    <item>
      <title>Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499227#M686231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My first foray into incremental loads is not going as planned &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt; I have used the following steps and am now somewhat stuck.&lt;/P&gt;&lt;P&gt;1. load previous qvd file&lt;/P&gt;&lt;P&gt;2. Create new table with max date of file&lt;/P&gt;&lt;P&gt;3. Set variable to equal max data from file (using let and peek statement)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;all of this works fine...i will drop the temp table once I can get this to work...my problem is getting the SQL Select (via ODBC connection) to recognise the variable within the where statement. I have tried a few different methods (preceding load, Setting the variable, letting the variable, adding quatations, removing quotations, but I cant get the syntax right. Any help would be greatly appreciated &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Jan 2014 23:53:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499227#M686231</guid>
      <dc:creator />
      <dc:date>2014-01-12T23:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499228#M686232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an idea for load script&lt;/P&gt;&lt;P&gt;[MaxDateTable]:&lt;/P&gt;&lt;P&gt;LOAD Max(LastModify) AS [MaxDate] FROM Transaction.qvd (qvd);&lt;/P&gt;&lt;P&gt;Let vMaxDate = Date(Peek('MaxDate',0,'MaxDateTable'),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;//LET vMaxDate = Date(Peek('MaxDate',0,'MaxDateTable'),'DD-MM-YYYY');&lt;/P&gt;&lt;P&gt;//LET vMaxDate =TIMESTAMP(Peek('MaxDate',0,'MaxDateTable'),'YYYY-MM-DD hh:mm:ss.fff');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP TABLE [MaxDateTable];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[TableSQL]:&lt;/P&gt;&lt;P&gt;SQL Select * FROM tblName WHERE LastModify &amp;gt; '$(vMaxDate)';&lt;/P&gt;&lt;P&gt;//SQL Select * FROM tblName WHERE LastModify &amp;gt; CHR(39) &amp;amp; $(vMaxDate) &amp;amp; CHR(39);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** You may test it line by line via "Comment" and "Uncomment"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you share your script here?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2014 01:15:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499228#M686232</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2014-01-13T01:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499229#M686234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick , I am suspecting, the problem with variable conversion into your date field datatype and syntax will change based on the DB Type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the DB is SQL Server ,&amp;nbsp; you don't to convert the variable into date format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE DATE_FIELD &amp;gt;= '$(vMaxDate)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the DB is Oracle, the syntax will depend on the DATE_FIELD data type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. If the DATE_FEILD data type is DATE then,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vMaxDate = Date(Peek('MAX_DATE') , 'YYYY-MM-DD') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT * FROM TABLE WHERE DATE_FIELD &amp;gt;= TO_DATE('$(vMaxDate)' , 'YYYY-MM-DD') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. If the DATE_FEILD data type is TIMESTAMP then,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vMaxDate = Date(Peek('MAX_DATE') , 'YYYY-MM-DD hh:mm:ss') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT * FROM TABLE WHERE DATE_FIELD &amp;gt;= TO_DATE('$(vMaxDate)' , 'YYYY-MM-DD HH24:MM:SS') ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: First test your SQL Where cond query outside qlikview like TOAD or any tool then use in Qlikview.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2014 15:32:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499229#M686234</guid>
      <dc:creator />
      <dc:date>2014-01-13T15:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499230#M686236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Sokkorn and Dathu for your helpful tips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can confirm that the SQL select statement works as intended in HeidiSQL, however when running via QV, it is erring as though [where Date &amp;gt; '$(vMaxNPS)';] is blank&amp;nbsp; (returns syntax equivalent to [where Date &amp;gt; '']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the feeling that the problem may lie in the variabel itself. When I call the field name in a text box (MaxNPSDate) i get the 5 digit value...but when i can the variable $(vMaxNPS) I get nothing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 00:50:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499230#M686236</guid>
      <dc:creator />
      <dc:date>2014-01-14T00:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499231#M686238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I can confirm that the SQL select statement works as intended in HeidiSQL, however when running via QV, it is erring as though [where Date &amp;gt; '$(vMaxNPS)';] is blank&amp;nbsp; (returns syntax equivalent to [where Date &amp;gt; '']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I get the feeling that the problem may lie in the variabel itself. When I call the field name in a text box (MaxNPSDate) i get the 5 digit value...but when i can the variable $(vMaxNPS) I get nothing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 00:50:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499231#M686238</guid>
      <dc:creator />
      <dc:date>2014-01-14T00:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499232#M686239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I can confirm that the SQL select statement works as intended in HeidiSQL, however when running via QV, it is erring as though [where Date &amp;gt; '$(vMaxNPS)';] is blank&amp;nbsp; (returns syntax equivalent to [where Date &amp;gt; '']&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;I get the feeling that the problem may lie in the variabel itself. When I call the field name in a text box (MaxNPSDate) i get the 5 digit value...but when i can the variable $(vMaxNPS) I get nothing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 00:50:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499232#M686239</guid>
      <dc:creator />
      <dc:date>2014-01-14T00:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499233#M686240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you share your script. So that we can find it out together; spot on why vMaxNPS return nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 01:04:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499233#M686240</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2014-01-14T01:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499234#M686241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sokkorn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've had to remove field names due to sensitivity, but here is the script. I also seem to have another problem in storing the newly acquired data into a separate qvd.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Load previos qvd file&lt;/P&gt;&lt;P&gt;NPS:&lt;/P&gt;&lt;P&gt;LOAD [8 Data Fields]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE_DATE, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [5 Fact Fields]&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;nps.qvd&lt;/P&gt;&lt;P&gt;(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Set max data date for file in sql format. This returns '2014-06-01' which is acceptable for MySQL however when calling the variable returns blank. &lt;/P&gt;&lt;P&gt;MaxNPSTable:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; Date(max(FILE_DATE),'YYYY-MM-DD') as MaxNPSDate&lt;/P&gt;&lt;P&gt;FROM NPS.qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//set variable to the max data date&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek(MaxNPSDate,0,MaxNPSTable),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODBC CONNECT TO SDCC;&lt;/P&gt;&lt;P&gt;NPSNEW:&lt;/P&gt;&lt;P&gt;SQL SELECT &lt;/P&gt;&lt;P&gt;Date as 'FILE_DATE', &lt;/P&gt;&lt;P&gt;[5 fact fields],&lt;/P&gt;&lt;P&gt;[8 data Fields]&lt;/P&gt;&lt;P&gt;FROM dashboarddata.nps&lt;/P&gt;&lt;P&gt;where Date &amp;gt; '$(vMaxNPS)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Store NPSNEW into NPSNEW.qvd(qvd);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 01:13:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499234#M686241</guid>
      <dc:creator />
      <dc:date>2014-01-14T01:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499235#M686242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you try this one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[MaxNPSTable]:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; Max(FILE_DATE) AS [MaxNPSDate]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM NPS.qvd (qvd);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;//set variable to the max data date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD');&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit: Changed log&lt;/P&gt;&lt;P&gt;1. Changed &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Date(max(FILE_DATE),'YYYY-MM-DD') to M&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;ax(FILE_DATE)&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;"&gt;2. Changed &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;LET vMaxNPS = Date(Peek(MaxNPSDate,0,MaxNPSTable),'YYYY-MM-DD'); to &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;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD');&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 01:19:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499235#M686242</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2014-01-14T01:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499236#M686243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sokkorn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I aplpied your changes and it has given much the same result. MaxNPSDate is equal to the excel equivalent of 6th january (41645) however when calling the variable within a text object to test it the result is 2007. (within the text object is =$(vMaxNPS)&lt;/P&gt;&lt;P&gt;also, when running the SQL extract it retrieves the entire table and appends it to the existing dataset within the QVW. I will try some more tomorrow...this one will not beat me!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 05:13:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499236#M686243</guid>
      <dc:creator />
      <dc:date>2014-01-14T05:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499237#M686244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As per your comments, the variable didn't have the date field,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the TRACE command to show the value of variable in the load script and also check the log file after fail, then you can see which value holding in the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRACE Max Date value ----&amp;gt; $(vMaxDate)&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please post your Variable definition in LET statement ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 14:10:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499237#M686244</guid>
      <dc:creator />
      <dc:date>2014-01-14T14:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499238#M686245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dathu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried a couple of variations for the LET statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD'); returns 2007 for some reason&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek(MaxNPSDate,0,MaxNPSTable),'YYYY-MM-DD'); returns -&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 23:38:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499238#M686245</guid>
      <dc:creator />
      <dc:date>2014-01-14T23:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499239#M686246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;TRACE of the vMaxNPS shows blank&lt;/P&gt;&lt;P&gt;and when I debug, the LET statement appears to read the field MaxNPSDate from the MaxNPSTable as NULL&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 01:17:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499239#M686246</guid>
      <dc:creator />
      <dc:date>2014-01-15T01:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499240#M686247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please post whole script what are you using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am suspecting the problem with &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;MaxNPSTable&lt;/STRONG&gt;&lt;/SPAN&gt; and how many values exist in this table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This table must have only one value and that would be maximum date value. Please dont drop the table and check what is the value on the table ? In the this table having only one date value then there shouldn't be &lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt; a &lt;/SPAN&gt;problem&lt;SPAN style="line-height: 1.5em; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 03:51:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499240#M686247</guid>
      <dc:creator />
      <dc:date>2014-01-15T03:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499241#M686248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dathu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table only contains a single value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the complete script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NPS:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;     FILE_DATE,&lt;/P&gt;&lt;P&gt;     &lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;nps.qvd&lt;/P&gt;&lt;P&gt;(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MaxNPSTable:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;       Max(FILE_DATE) AS &lt;/P&gt;&lt;P&gt;FROM NPS.qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ODBC CONNECT TO SDCC;&lt;/P&gt;&lt;P&gt;NPSNEW:&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;Date as 'FILE_DATE',&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM dashboarddata.nps&lt;/P&gt;&lt;P&gt;where Date &amp;gt; $(vMaxNPS);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 04:04:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499241#M686248</guid>
      <dc:creator />
      <dc:date>2014-01-15T04:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499242#M686249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;NPS:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FILE_DATE,&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM nps.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;MaxNPSTable:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD Max(FILE_DATE) AS MaxNPSDate &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM NPS.qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LET vMaxNPS = Date(Peek('MaxNPSDate'),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;ODBC CONNECT TO SDCC;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;NPSNEW:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL SELECT&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Date as 'FILE_DATE',&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM dashboarddata.nps&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;where Date &amp;gt; '$(vMaxNPS)';&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;if not work, what is value you are getting in the MaxNPSTable (date or string) ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 04:20:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499242#M686249</guid>
      <dc:creator />
      <dc:date>2014-01-15T04:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499243#M686250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please load two statement below only and give me the result:&lt;/P&gt;&lt;P&gt;MaxNPSTable:&lt;/P&gt;&lt;P&gt;LOAD Max(FILE_DATE) AS [MaxNPSDate] FROM NPS.qvd (qvd);&lt;/P&gt;&lt;P&gt;// What is the value of field [MaxNPSDate]?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;// What is the value of variable vMaxNPS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Awaiting your prompt response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 06:33:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499243#M686250</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2014-01-15T06:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499244#M686251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sokkorn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MaxNPSTable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD Max(FILE_DATE) AS  FROM NPS.qvd (qvd);&lt;/P&gt;&lt;P&gt;Returns a value of 41645 (excel equivalent of 6th Jan 2014)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS = Date(Peek('MaxNPSDate',0,'MaxNPSTable'),'YYYY-MM-DD');&lt;/P&gt;&lt;P&gt;When specified as =vMaxNPS shows 2014-01-06 but when specified as =$(vMaxNPS) shows 2007&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 06:43:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499244#M686251</guid>
      <dc:creator />
      <dc:date>2014-01-15T06:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499245#M686252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my test&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/51526_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Result after load&lt;/P&gt;&lt;P&gt;&lt;IMG alt="2.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/51542_2.png" /&gt;&lt;/P&gt;&lt;P&gt;You see the line that I use TRACE function with $(vMaxNPS), then it return 2014-01-06. Not sure why you got 2007&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sokkorn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 10:15:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499245#M686252</guid>
      <dc:creator>Sokkorn</dc:creator>
      <dc:date>2014-01-15T10:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable within SQL select statement</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499246#M686253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick, can you check what is your SET DateFormat variable ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try Like below: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMaxNPS&amp;nbsp; =&amp;nbsp; text(Date(Peek('MaxNPSDate'),'YYYY-MM-DD')) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;ODBC CONNECT TO SDCC;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;NPSNEW:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL SELECT&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Date as 'FILE_DATE',&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;, &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;FROM dashboarddata.nps&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;where Date &amp;gt; '$(vMaxNPS)';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 13:50:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-within-SQL-select-statement/m-p/499246#M686253</guid>
      <dc:creator />
      <dc:date>2014-01-15T13:50:30Z</dc:date>
    </item>
  </channel>
</rss>

