<?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: Cannot use variable inside SQL in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281278#M861348</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need a LET &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;LET&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; CargarDesde = year(today());&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;trace $(CargarDesde);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;instead of SET&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;EM&gt;SET&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; CargarDesde = year(today());&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;EM&gt;trace $(CargarDesde);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jan 2017 17:44:41 GMT</pubDate>
    <dc:creator>maxgro</dc:creator>
    <dc:date>2017-01-19T17:44:41Z</dc:date>
    <item>
      <title>Cannot use variable inside SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281275#M861345</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;I want to load a SQL sentence &lt;SPAN style="font-size: 13.3333px;"&gt;dinamically &lt;/SPAN&gt;limited by the last year (2016). But it seems to be that QliKView is not replacing the variable with the year. Any idea why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14848467007268722" jivemacro_uid="_14848467007268722"&gt;
&lt;P&gt;SET CargarDesde = year(today());&lt;/P&gt;
&lt;P&gt;SET RepositorioXLS='..\Datos Externos\XLS\Estado de Resultados\';&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;.....................&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Kilos:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SQL Select&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;From dba.costo_tipomovtocantidades ct&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;LEFT JOIN dba.especies ON ct.espe_codigo=especies.espe_codigo&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LEFT JOIN dba.costo_gerencias ON ct.plde_codigo=costo_gerencias.plde_codigo&lt;/P&gt;
&lt;P&gt;Group By ctmc_period, ctmc_nromes, ct.espe_codigo, espe_nombre, coge_codigo, coge_nombre, ctmv_codigo, ctmc_tipser&lt;/P&gt;
&lt;P&gt;Having ctmc_period&amp;gt;=&lt;STRONG style=": ; color: #ff0000;"&gt;$(CargarDesde);&lt;/STRONG&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thi is the error it gives to me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ErrorSource: (null), ErrorMsg: (null)&lt;/P&gt;&lt;P&gt;Kilos:&lt;/P&gt;&lt;P&gt;SQL Select&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;From dba.costo_tipomovtocantidades ct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN dba.especies ON ct.espe_codigo=especies.espe_codigo&lt;/P&gt;&lt;P&gt;&amp;nbsp; LEFT JOIN dba.costo_gerencias ON ct.plde_codigo=costo_gerencias.plde_codigo&lt;/P&gt;&lt;P&gt;Group By ctmc_period, ctmc_nromes, ct.espe_codigo, espe_nombre, coge_codigo, coge_nombre, ctmv_codigo, ctmc_tipser&lt;/P&gt;&lt;P&gt;Having ctmc_period&amp;gt;&lt;STRONG style="color: #ff0000;"&gt;=year(today())&lt;/STRONG&gt;&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/Cannot-use-variable-inside-SQL/m-p/1281275#M861345</guid>
      <dc:creator>cristian_av</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use variable inside SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281276#M861346</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;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;Having&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; ctmc_period &amp;gt;= '$(CargarDesde)';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt !important; font-style: inherit; background-color: inherit; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt !important; font-style: inherit; background-color: inherit; font-weight: inherit;"&gt;Regards, &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:34:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281276#M861346</guid>
      <dc:creator>eespiritu</dc:creator>
      <dc:date>2017-01-19T17:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use variable inside SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281277#M861347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the value coming from ctmc_period ? Is that a date or a year value in that? Try some thing like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;Kilos:&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;LOAD *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;WHERE ctmc_period &amp;gt;= '$(cargarDesde)' ; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;SQL &lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;*&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;From&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; dba.costo_tipomovtocantidades ct&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;&lt;SPAN class="func" style="font-weight: inherit; font-style: inherit; color: #ff1493; background-color: inherit; font-size: 9pt !important;"&gt;LEFT&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; &lt;/SPAN&gt;&lt;SPAN class="op" style="font-weight: inherit; font-style: inherit; color: #808080; background-color: inherit; font-size: 9pt !important;"&gt;JOIN&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; dba.especies &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; ct.espe_codigo=especies.espe_codigo&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;&amp;nbsp; &lt;SPAN class="func" style="font-weight: inherit; font-style: inherit; color: #ff1493; background-color: inherit; font-size: 9pt !important;"&gt;LEFT&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; &lt;/SPAN&gt;&lt;SPAN class="op" style="font-weight: inherit; font-style: inherit; color: #808080; background-color: inherit; font-size: 9pt !important;"&gt;JOIN&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; dba.costo_gerencias &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;ON&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; ct.plde_codigo=costo_gerencias.plde_codigo&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; color: black; background-color: inherit; font-size: 9pt !important;"&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;Group&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-weight: inherit; font-style: inherit; color: #006699; background-color: inherit; font-size: 9pt !important;"&gt;By&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; background-color: inherit; font-size: 9pt !important;"&gt; ctmc_period, ctmc_nromes, ct.espe_codigo, espe_nombre, coge_codigo, coge_nombre, ctmv_codigo, ctmc_tipser&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 9pt !important; font-style: inherit; background-color: inherit; font-weight: inherit;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:36:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281277#M861347</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-01-19T17:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use variable inside SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281278#M861348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need a LET &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;LET&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; CargarDesde = year(today());&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;trace $(CargarDesde);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;instead of SET&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;EM&gt;SET&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; CargarDesde = year(today());&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;EM&gt;trace $(CargarDesde);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jan 2017 17:44:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281278#M861348</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2017-01-19T17:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot use variable inside SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281279#M861349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Seen several threads on this but this is the only one that works for me. Not sure what is the difference using LET or SET. Thanks Massimo Grossi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 01:04:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Cannot-use-variable-inside-SQL/m-p/1281279#M861349</guid>
      <dc:creator>calvin_wee</dc:creator>
      <dc:date>2017-04-03T01:04:26Z</dc:date>
    </item>
  </channel>
</rss>

