<?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: Variables in load script string formula in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943968#M77785</link>
    <description>&lt;P&gt;Hello Rob,&lt;/P&gt;
&lt;P&gt;thank you very much for your answer.&lt;/P&gt;
&lt;P&gt;I have tried adding '&amp;amp;' symbol to the string but the result is unfortunately the same. Nothing changes in the formula if I change vSelect value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 11:27:10 GMT</pubDate>
    <dc:creator>MPkg</dc:creator>
    <dc:date>2022-06-15T11:27:10Z</dc:date>
    <item>
      <title>Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943229#M77724</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to make&amp;nbsp; a chart formula inside of the load script as a string. Everything works as it should except one thing.&lt;/P&gt;
&lt;P&gt;When I try to implement a variable inside the string formula I get a situation that this variable cannot be changed any more, in other words it becomes a constant with a value equals the value it had in the moment of loading the script.&lt;/P&gt;
&lt;P&gt;*For example,&lt;/P&gt;
&lt;P&gt;if I try to make this formula in the load script:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;load script:

let vChartFormula = 'SUM({"$(vSelect)"}Month)';

let vSelect = 'January';
&lt;/LI-CODE&gt;
&lt;P&gt;and when I now use this variable vChartFormula in the chart I only get formula like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;chart function:
SUM({"January"}Month)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;and anything I change in variable vSelect does not impact the chart function.&lt;/P&gt;
&lt;P&gt;I can set vSelect = 'February', nothing changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Am I doing something wrong, or is this not possible in Qlik Sense at the moment?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 09:27:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943229#M77724</guid>
      <dc:creator>MPkg</dc:creator>
      <dc:date>2022-06-14T09:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943734#M77760</link>
      <description>&lt;P&gt;The $(vSelect) gets substituted in the script. You can avoid this problem by coding your let like:&lt;/P&gt;
&lt;P&gt;let vChartFormula = 'SUM({"$' &amp;amp; '(vSelect)"}Month)';&lt;/P&gt;
&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 04:09:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943734#M77760</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2022-06-15T04:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943968#M77785</link>
      <description>&lt;P&gt;Hello Rob,&lt;/P&gt;
&lt;P&gt;thank you very much for your answer.&lt;/P&gt;
&lt;P&gt;I have tried adding '&amp;amp;' symbol to the string but the result is unfortunately the same. Nothing changes in the formula if I change vSelect value.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 11:27:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1943968#M77785</guid>
      <dc:creator>MPkg</dc:creator>
      <dc:date>2022-06-15T11:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944070#M77794</link>
      <description>&lt;P&gt;I would expect it to change. However,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;SUM({"January"}Month)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;is not a valid expression so it may not be helpful if it did.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Can you post the contents of vChartFormula from the Variable Editor?&lt;/P&gt;
&lt;P&gt;2. What are you trying to calculate with this vChartFormula?&lt;/P&gt;
&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 14:25:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944070#M77794</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2022-06-15T14:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944121#M77801</link>
      <description>&lt;P&gt;I also wondering what here is being calculated. I find it difficult to make a sum of a month? Anyway, I think the set analysis/expression isn't correct:&lt;/P&gt;
&lt;P&gt;Sum ({$&amp;lt;Month="January"&amp;gt;} Month)&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;Sum ({$&amp;lt;Month="$(&lt;SPAN&gt;vSelect&lt;/SPAN&gt;)"&amp;gt;} Month)&lt;/P&gt;
&lt;P&gt;And don't forget&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;&amp;nbsp;advice for loading the variable in the loadscript like he mentioned. If you are looking for other suggestions, then we need more information I guess..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Eddie&lt;/P&gt;
&lt;TABLE style="border-style: solid; width: 100%; border-color: #006B30;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%" style="background-color: #009845; width: 100%; border-style: solid;"&gt;&lt;FONT color="#FFFFFF"&gt;If this answers your question or solves your issue, be sure to mark the answer as correct by clicking '&lt;STRONG&gt;&lt;SPAN class="notion-enable-hover" data-token-index="1" data-reactroot=""&gt;Accept as Solution&lt;/SPAN&gt;&lt;/STRONG&gt;'. This will mark the post as solved and other Qlikkies will gravitate towards this post as it as a possible solution for their issue.&amp;nbsp;Multiple responses can be accepted as a solution so make sure to select all that apply.&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 15 Jun 2022 15:09:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944121#M77801</guid>
      <dc:creator>eddie_wagt</dc:creator>
      <dc:date>2022-06-15T15:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944500#M77832</link>
      <description>&lt;P&gt;Hello Rob and Eddie,&lt;/P&gt;
&lt;P&gt;The code for expression is correct as&amp;nbsp;&lt;SPAN&gt;{"January"} represents the name of the bookmark that I want to apply to the field. It is true that Sum of Month sounds strange but it should be only a random name of a Field. You can take any data for this field, for example Costs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I want to make a &lt;SPAN&gt;SUM({"January"}Costs) for Bookmark selection named January.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you both for the fast reply, but I tried with '&amp;amp;' and it did not work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 10:53:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944500#M77832</guid>
      <dc:creator>MPkg</dc:creator>
      <dc:date>2022-06-16T10:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944536#M77835</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Ah now I see what you mean.&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SET vChartFormula_tmp= "SUM({/#(vSelect)/}Month)";
LET vChartFormula = replace(replace(vChartFormula_tmp,'#','$'),'/','"');
LET vChartFormula_tmp = NULL();
let vSelect = 'January';

LOAD * INLINE [Month, Costs
January,100
February,200
];&lt;/LI-CODE&gt;
&lt;P&gt;In Expression&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM({"$(vSelect)"}Costs)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="eddie_wagt_0-1655380949723.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/81927i753C39B7A57DA9F9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="eddie_wagt_0-1655380949723.png" alt="eddie_wagt_0-1655380949723.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Regards Eddie&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 12:02:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944536#M77835</guid>
      <dc:creator>eddie_wagt</dc:creator>
      <dc:date>2022-06-16T12:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Variables in load script string formula</title>
      <link>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944943#M77875</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have accepted both of your answers because they are correct.&lt;/P&gt;
&lt;P&gt;I realized&amp;nbsp; that I have another problem in my formula. So maybe you can help me with this as well.&lt;/P&gt;
&lt;P&gt;I am using for loop in load script to make a formula like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;for i = 1 to 5
let vChartFormula_$(i) = 'SUM({"$(vSelect)"}Cost_$(i))'

if i = 1
   let vChartFormula = '$(vChartFormula_$(i))';
else
   let vChartFormula = '$(vChartFormula)'&amp;amp;'+'&amp;amp;'$(vChartFormula_$(i))';
end if
next i

let vSelect = 'January';&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This is why I cannot change vSelect value in chart expression after entering the formula to the chart.&lt;/P&gt;
&lt;P&gt;Do you have some solution to this case, what to change in the load script so I can set vSelect = 'February' in the chart expression?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 07:50:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variables-in-load-script-string-formula/m-p/1944943#M77875</guid>
      <dc:creator>MPkg</dc:creator>
      <dc:date>2022-06-17T07:50:23Z</dc:date>
    </item>
  </channel>
</rss>

