<?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: defining variable in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505488#M685843</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you want to do this in your script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your expression can be calculated in the front end. It will be dynamic too, displaying the current selection as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your goal is to always calculate for the max date you can add to your set analysis the following statements:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Sum({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;$(=Year(Max(date1))-1)},month1={$(=Month(Max(date1))), year = , mont =, &lt;/SPAN&gt;&amp;gt;}amount1)&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;&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;"&gt;The year = and month = statements eliminate the selections done on these dimensions in list boxes.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jan 2014 14:18:30 GMT</pubDate>
    <dc:creator>Michiel_QV_Fan</dc:creator>
    <dc:date>2014-01-14T14:18:30Z</dc:date>
    <item>
      <title>defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505486#M685839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i want to include a set analysis expression in script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;variable name&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;condition1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;definition&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;year1={$(=Year(Max(date1))-1)},month1={$(=Month(Max(date1)))}&lt;/P&gt;&lt;P&gt;// where year1,month1 and date1 are attributes from my data source&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;expression&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;Sum({&amp;lt;$(condition1)&amp;gt;}amount1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this can be easily done by storing it through "Settings"&amp;gt;"Variable Overview"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but how can i manage the variable condition1 in "edit script"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is quite confusing to me for when to apply dollar sign, using let or set, ... etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have read blogs from Henric, but i still don't understand how to do it&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/11/04/the-magic-of-variables" title="http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/04/the-magic-of-variables"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/04/the-magic-of-variables&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/blogs/qlikviewdesignblog/2013/11/18/dollar-expansions" title="http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/18/dollar-expansions"&gt;http://community.qlik.com/blogs/qlikviewdesignblog/2013/11/18/dollar-expansions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 08:14:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505486#M685839</guid>
      <dc:creator>laujerry</dc:creator>
      <dc:date>2014-01-14T08:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505487#M685841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set analysis doesn't work in script unfortunately. you'll have to develop a specific script that performs the logic of your set analysis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT:&lt;BR /&gt;SET command fixes the content of your variable.&lt;/P&gt;&lt;P&gt;i.e. SET x = 1+2&lt;/P&gt;&lt;P&gt;When interpreted by using dollar sign expansion $(x) will give 1 +2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET x = 1+ 2&lt;/P&gt;&lt;P&gt;When interpreted $(x) will give 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 14:00:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505487#M685841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-01-14T14:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505488#M685843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why do you want to do this in your script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your expression can be calculated in the front end. It will be dynamic too, displaying the current selection as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your goal is to always calculate for the max date you can add to your set analysis the following statements:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Sum({&amp;lt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;$(=Year(Max(date1))-1)},month1={$(=Month(Max(date1))), year = , mont =, &lt;/SPAN&gt;&amp;gt;}amount1)&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;&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;"&gt;The year = and month = statements eliminate the selections done on these dimensions in list boxes.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 14:18:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505488#M685843</guid>
      <dc:creator>Michiel_QV_Fan</dc:creator>
      <dc:date>2014-01-14T14:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505489#M685845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jerry,&lt;/P&gt;&lt;P&gt;Hope are doing well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find below the differences:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;SET: is used in the script to store value (text/numeric) in a variable&lt;/LI&gt;&lt;LI&gt;LET: is used in the script to store a value having some Qlikview function in a variable&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Just type below two commands in your script editor&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SET vName1=Upper(Jerry);&lt;/P&gt;&lt;P&gt;LET vName2= Upper(Jerry);&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Debug/Load the script&lt;/LI&gt;&lt;LI&gt;Check the values stored under these two variables&lt;/LI&gt;&lt;LI&gt;Even while defining them in the script, you can see the difference in color, Suggestion starts appearing&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 3.&amp;nbsp; Dollar sign expansion (DSE): is used to resolve/ refer a variable which contains numeric value or uses Qlikview functions. It can not be used to resolve a variable which contains text value e.g. vName1 in above case. DSE is not desired if the variable contains some plain number, but its a good practice to use DSE.&lt;/P&gt;&lt;P&gt;DSE should not be used to resolve variable which contains Text value, else it will output a null/ missing value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 15:07:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505489#M685845</guid>
      <dc:creator>gopalopsharma</dc:creator>
      <dc:date>2014-01-14T15:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505490#M685848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for your answers&lt;/P&gt;&lt;P&gt;but i get the solution from an older post: &lt;A href="https://community.qlik.com/message/406565"&gt;Putting Dollar Expansion in Variable&lt;/A&gt;&lt;/P&gt;&lt;P&gt;either&lt;/P&gt;&lt;P&gt;1) using Replace() function (but that does not work for me, i don't know why)&lt;/P&gt;&lt;P&gt;2) split the string after any dollar sign and concatenate segments manually&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 07:24:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/505490#M685848</guid>
      <dc:creator>laujerry</dc:creator>
      <dc:date>2014-01-17T07:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/1650574#M685849</link>
      <description>&lt;P&gt;hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;would you please explain me this.&lt;/P&gt;&lt;P&gt;Let &amp;nbsp;x=left(y,2)&lt;/P&gt;&lt;P&gt;"y" is one of my column in a table.&lt;/P&gt;&lt;P&gt;how can i replace y to other columns,&lt;/P&gt;&lt;P&gt;for instance if&lt;/P&gt;&lt;P&gt;= x (Z),&lt;/P&gt;&lt;P&gt;the the answer be the same as = left(Z,2),&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 10:23:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/1650574#M685849</guid>
      <dc:creator>Hamid_Reza_Rashidi</dc:creator>
      <dc:date>2019-11-25T10:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: defining variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/1705320#M685851</link>
      <description>&lt;P&gt;look for variable with parameters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but here is the short version&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define x as:&lt;/P&gt;&lt;P&gt;Left($1,2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you may call it like:&lt;/P&gt;&lt;P&gt;$(x(Z))&lt;/P&gt;&lt;P&gt;and that will expand to&lt;/P&gt;&lt;P&gt;Left(Z, 2)&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 17:52:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/defining-variable-in-script/m-p/1705320#M685851</guid>
      <dc:creator>JuanManuelLopezFelizzola</dc:creator>
      <dc:date>2020-05-26T17:52:46Z</dc:date>
    </item>
  </channel>
</rss>

