<?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 Create variable in script vs variable settings in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Create-variable-in-script-vs-variable-settings/m-p/1992646#M82142</link>
    <description>&lt;P&gt;I'm fond of the new syntax for set analysis and is experimenting to put set expressions into master items. At this point I also try to read these expressions from variables. I do see problems when creating such variable in script vs in variable area.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;In script I create:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;LET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';&lt;/LI&gt;
&lt;LI&gt;SET vSA_MaxDateMonthEnd = {&amp;lt;Källa={'ANST_Månad'}&amp;gt;}{&amp;lt;Datum={"&amp;gt;=$(vMaxDateMonthEnd)"}&amp;gt;};&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;After script load I have the following variable in variable area, see picture. I have no problem, though, to CREATE such variable in variable area (even if the syntax check complains) and use it accordingly in my application.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So there is a solution but I do prefer creating variables in script for reuse and source control. Is there a script solution to make the variable to 'stay' as defined in the SET creation? I do have tried many different syntax alternatives but they all end up as:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;{&amp;lt;Källa={'ANST_Månad'}&amp;gt;}{&amp;lt;Datum={"&amp;gt;==MonthEnd(Date(Max(Datum)))"}&amp;gt;}&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It is the expansion of&amp;nbsp;$(vMaxDateMonthEnd) that ruins my day.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Oct 2022 09:02:46 GMT</pubDate>
    <dc:creator>Hakan_Hansson</dc:creator>
    <dc:date>2022-10-14T09:02:46Z</dc:date>
    <item>
      <title>Create variable in script vs variable settings</title>
      <link>https://community.qlik.com/t5/App-Development/Create-variable-in-script-vs-variable-settings/m-p/1992646#M82142</link>
      <description>&lt;P&gt;I'm fond of the new syntax for set analysis and is experimenting to put set expressions into master items. At this point I also try to read these expressions from variables. I do see problems when creating such variable in script vs in variable area.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;In script I create:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;LET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';&lt;/LI&gt;
&lt;LI&gt;SET vSA_MaxDateMonthEnd = {&amp;lt;Källa={'ANST_Månad'}&amp;gt;}{&amp;lt;Datum={"&amp;gt;=$(vMaxDateMonthEnd)"}&amp;gt;};&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;After script load I have the following variable in variable area, see picture. I have no problem, though, to CREATE such variable in variable area (even if the syntax check complains) and use it accordingly in my application.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So there is a solution but I do prefer creating variables in script for reuse and source control. Is there a script solution to make the variable to 'stay' as defined in the SET creation? I do have tried many different syntax alternatives but they all end up as:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;{&amp;lt;Källa={'ANST_Månad'}&amp;gt;}{&amp;lt;Datum={"&amp;gt;==MonthEnd(Date(Max(Datum)))"}&amp;gt;}&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;It is the expansion of&amp;nbsp;$(vMaxDateMonthEnd) that ruins my day.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 09:02:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-variable-in-script-vs-variable-settings/m-p/1992646#M82142</guid>
      <dc:creator>Hakan_Hansson</dc:creator>
      <dc:date>2022-10-14T09:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create variable in script vs variable settings</title>
      <link>https://community.qlik.com/t5/App-Development/Create-variable-in-script-vs-variable-settings/m-p/1992725#M82147</link>
      <description>&lt;P&gt;Hi, try it like this instead:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;SET vMaxDateMonthEnd = '=MonthEnd(Date(Max(Datum)))';
LET vSA_MaxDateMonthEnd = REPLACE(REPLACE('{&amp;lt;Källa={‘ANST_Månad‘}&amp;gt;},{&amp;lt;Datum={"&amp;gt;=#(vMaxDateMonthEnd)"}&amp;gt;}','‘',CHR(39)),'#','$');&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 14 Oct 2022 11:42:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-variable-in-script-vs-variable-settings/m-p/1992725#M82147</guid>
      <dc:creator>RsQK</dc:creator>
      <dc:date>2022-10-14T11:42:15Z</dc:date>
    </item>
  </channel>
</rss>

