<?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: How to use Qlikview dashboard variables in SQL script used to load data in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059050#M924414</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonthan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query works fine in following format&lt;/P&gt;&lt;P&gt;&lt;EM&gt;select a,b&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [table 1]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;where date in ('28-mar-2016', '27-mar-2016','21-mar-2016','28-feb-2016','28-mar-2016');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But the problem is DB stores data in timestamp format, hence I need to do conversion when I am defining other 4 variables based on vuserdate. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I tried running SQL query in debug mode turns out Query is recognizing the vuserdate but does not do further derivation of the variables.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;my formula for Previous date : &lt;SPAN style="font-size: 12pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;((&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;)-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;),'WWW')='Mon',3,1) &lt;/SPAN&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;also tried : &lt;SPAN style="font-size: 12pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date#&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;,'DD-MMM-YYYY')- &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date#&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;,'DD-MMM-YYYY'),'WWW')='Mon',3,1) ,'DD-MMM-YYYY') &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 12pt;"&gt;the second format displays the date correctly in the Dashboard.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Apr 2016 17:19:53 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-04-05T17:19:53Z</dc:date>
    <item>
      <title>How to use Qlikview dashboard variables in SQL script used to load data</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059048#M924412</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 have a variable vuserdate where user inputs date in the dashboard (eg: '28-mar-2016') and 4 other variables - prevday,7prevday,prevmonthday,prevyearday which are derived from vuserdate.&lt;/P&gt;&lt;P&gt;I want to refer these variables in SQL query in Script editor so that Qlikview only loads data for these 5 date variables instead of full year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried following queries:&lt;/P&gt;&lt;P&gt;select a,b&lt;/P&gt;&lt;P&gt;from table 1&lt;/P&gt;&lt;P&gt;where date in ($(vuserdate), $(prevday),$(7prevday),$(prevmonthday),$(prevyearday))&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;select a,b&lt;/P&gt;&lt;P&gt;from table 1&lt;/P&gt;&lt;P&gt;where date in ('$(vuserdate)', '$(prevday)','$(7prevday)','$(prevmonthday)','$(prevyearday)')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059048#M924412</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Qlikview dashboard variables in SQL script used to load data</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059049#M924413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to ensure that the variables are formatted with the correct date format for your SQL server. Try the query with the literal values first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;select a,b&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [table 1]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;where date in ('28-mar-2016', '27-mar-2016','21-mar-2016','28-feb-2016','28-mar-2016');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that works, then you know that the date format is OK. Then ensure that the variables are being formatted in the way you tested. The second script with the quotes is correct, but I suspect your date format is incorrect for SQL DB server or your variables contain incorrect values. If you run in debug mode you can confirm that the variables are being set correctly and see the query actually passed to the SQL DB.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Apr 2016 15:52:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059049#M924413</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2016-04-05T15:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Qlikview dashboard variables in SQL script used to load data</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059050#M924414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonthan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query works fine in following format&lt;/P&gt;&lt;P&gt;&lt;EM&gt;select a,b&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from [table 1]&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;where date in ('28-mar-2016', '27-mar-2016','21-mar-2016','28-feb-2016','28-mar-2016');&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;But the problem is DB stores data in timestamp format, hence I need to do conversion when I am defining other 4 variables based on vuserdate. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I tried running SQL query in debug mode turns out Query is recognizing the vuserdate but does not do further derivation of the variables.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;my formula for Previous date : &lt;SPAN style="font-size: 12pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;((&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;)-&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;),'WWW')='Mon',3,1) &lt;/SPAN&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;also tried : &lt;SPAN style="font-size: 12pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date#&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;,'DD-MMM-YYYY')- &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt;"&gt;date#&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;(&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;vEndDate&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt;"&gt;,'DD-MMM-YYYY'),'WWW')='Mon',3,1) ,'DD-MMM-YYYY') &lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 12pt;"&gt;the second format displays the date correctly in the Dashboard.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Apr 2016 17:19:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-Qlikview-dashboard-variables-in-SQL-script-used-to/m-p/1059050#M924414</guid>
      <dc:creator />
      <dc:date>2016-04-05T17:19:53Z</dc:date>
    </item>
  </channel>
</rss>

