<?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: Nested variables are broken? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422703#M33841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting. The doubling of the single quotes seems to be QS trying to be helpful by escaping the single quotes. I can reproduce your example and problem in QS Desktop Sept 2017.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET does not do evaluation as LET does, but it does do DSE (substitution for $()).&amp;nbsp; I note your use of " around your set values.&amp;nbsp; The doc is unclear on this. It's shown in the examples with no explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However...SET is very greedy, it will grab everything up to the semicolon. I never use quotes around my string regardless of it's contents.&amp;nbsp; So you can code your statements like this without the outside quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_uptime = Sum({&amp;lt;Status={'Running'}&amp;gt;} m_minutes); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_plannedUptime = Sum({&amp;lt;Status-={'Planned Down'}&amp;gt;} m_minutes); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_availability = $(v_uptime) / $(v_plannedUptime);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives the desired result in both QV and QS. &lt;/P&gt;&lt;P&gt;&lt;IMG alt="2017-11-06_17-59-25.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/182301_2017-11-06_17-59-25.png" style="height: 101px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Nov 2017 23:01:21 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2017-11-06T23:01:21Z</dc:date>
    <item>
      <title>Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422699#M33837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an app that I made in Qlik Sense Desktop, and it worked 100% fine there.&amp;nbsp; Now that we are paying to run Qlik Sense on an &lt;SPAN style="font-size: 13.3333px;"&gt;on-premises&lt;/SPAN&gt; server, I am trying to get this app moved over to it and having great difficulty.&amp;nbsp; &lt;SPAN style="font-size: 10pt;"&gt;In the desktop version, I could compose variables from other variables, and it worked just fine, like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_15099930093322069" jivemacro_uid="_15099930093322069"&gt;
&lt;P&gt;Set v_uptime = "Sum({&amp;lt;Status={'Running'}&amp;gt;} m_minutes)";&lt;/P&gt;
&lt;P&gt;Set v_plannedUptime = "Sum({&amp;lt;Status-={'Planned Down'}&amp;gt;} m_minutes)";&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Set v_availability = "$(v_uptime) / $(v_plannedUptime)";&lt;/SPAN&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;What I would see for the variable v_availability from the app side was this, as expected:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_1509993034700512" jivemacro_uid="_1509993034700512" modifiedtitle="true"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Sum({&amp;lt;Status={'Running'}&amp;gt;} m_minutes) / &lt;SPAN style="font-size: 13.3333px;"&gt;Sum({&amp;lt;Status-={'Planned Down'}&amp;gt;} m_minutes)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Now that I'm no longer using the desktop version, this is what I see on the app side instead:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15099930436242531 jive_text_macro" jivemacro_uid="_15099930436242531"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Sum({&amp;lt;Status={'Running'}&amp;gt;} m_minutes) / &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Sum({&amp;lt;Status-={''Planned Down''}&amp;gt;} m_minutes)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Note how it inserted an extra pair of quotation marks around 'Planned Down', breaking the formula and killing my charts and graphs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I've noticed that each time you nest a variable inside another one, you get an extra pair of quotes.&amp;nbsp; Here's an example:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15099942777666520 jive_text_macro" jivemacro_uid="_15099942777666520" modifiedtitle="true"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set v_uptimeSorters = "Sum({&amp;lt;Status={'Running'}, [Machine Type]={'Sorter'}&amp;gt;} m_minutes)";&lt;/P&gt;
&lt;P&gt;Set v_plannedUptimeSorters = "Sum({&amp;lt;Status-={'Planned Down'}, [Machine Type]={'Sorter'}&amp;gt;} m_minutes)";&lt;/P&gt;
&lt;P&gt;Set v_availabilitySorters = "$(v_uptimeSorters) / $(v_plannedUptimeSorters)";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set v_piecesSorters = "Sum({&amp;lt;[Machine Type]={'Sorter'}&amp;gt;} m_goodCount)";&lt;/P&gt;
&lt;P&gt;Set v_idealPerfPiecesSorters = "Sum({&amp;lt;Status={'Running'}, [Machine Type]={'Sorter'}&amp;gt;} m_idealRate * m_minutes)";&lt;/P&gt;
&lt;P&gt;Set v_performanceSorters = "$(v_piecesSorters) / $(v_idealPerfPiecesSorters)";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set v_qualitySorters = "1";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Set v_OEESorters = "$(v_performanceSorters) * $(v_availabilitySorters) * $(v_qualitySorters)";&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;IMG __jive_id="182296" alt="v_OEESorters.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/182296_v_OEESorters.png" style="height: 240px; width: 620px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I tried removing the variable-creating code from the script, re-loading the data, deleting all the variables from the app, putting the variable-creating code back into the script, and re-loading the data.&amp;nbsp; This did not fix the problem and produced 2 more glitches!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first new glitch is that some formulas now appear incomplete, like this:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_15099933038041039 jive_text_macro" jivemacro_uid="_15099933038041039"&gt;
&lt;P&gt;Set v_piecesRollers = "Sum({&amp;lt;[Machine Type]={'Roller'}&amp;gt;} m_goodCount)";&lt;/P&gt;
&lt;P&gt;Set v_count = "($(v_piecesRollers) + Sum({&amp;lt;[Machine Type]-={'Roller'}&amp;gt;} m_cycles))";&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;IMG __jive_id="182297" alt="incomplete.png" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/182297_incomplete.png" style="height: 146px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;The second new glitch is that some formulas are totally missing and replaced with asterisks, like this:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="182299" alt="asterisks.png" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/182299_asterisks.png" style="height: 218px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;What on earth is going on here?!&amp;nbsp; It would appear that Qlik's variable system is broken in the server version, but I'm trying not to jump to that conclusion and be open to the idea that I'm somehow doing something wrong here.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Nov 2024 09:05:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422699#M33837</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2024-11-16T09:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422700#M33838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael, seems the $-expansion is not working, this usually tries to calculate the expression, an inside the script it returns null(), you can try using a different character and a replace, ie:&lt;/P&gt;&lt;P&gt;Set v_piecesRollers = "Sum({&amp;lt;[Machine Type]={'Roller'}&amp;gt;} m_goodCount)";&lt;/P&gt;&lt;P&gt;Let v_count = Replace(Replace('&lt;SPAN style="color: #ff0000;"&gt;#&lt;/SPAN&gt;(v_piecesRollers) + Sum({&amp;lt;[Machine Type]-={&lt;SPAN style="color: #0000ff;"&gt;^&lt;/SPAN&gt;Roller&lt;SPAN style="color: #0000ff;"&gt;^&lt;/SPAN&gt;}&amp;gt;} m_cycles)',&lt;SPAN style="color: #ff0000;"&gt; '#', '$'&lt;/SPAN&gt;), &lt;SPAN style="color: #0000ff;"&gt;'^', Chr(39)&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using Let needs the use of simple quotes, so simple quotes needs to be replace by another character (in this case '^'), and then replaced again with simple quote. Chr(39) is the code for a simple quote.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2017 20:47:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422700#M33838</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2017-11-06T20:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422701#M33839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand your workaround and may give it a try - thanks.&amp;nbsp; However, I'm very curious: does $-expansion not work in general on Qlik Sense Server?&amp;nbsp; Or is this abnormal?&amp;nbsp; Do you think this points to something being wrong with our installation?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2017 21:06:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422701#M33839</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2017-11-06T21:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422702#M33840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm more used to QlikView, and in QV it's normal, loading it from excel or any other source and then assigning it to a variable seems to avoid the auto-calculation of $(.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mainly the idea is to avoid write '$(' in script when you want to keep the text as it was written, not trying to evaluate the content.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2017 22:18:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422702#M33840</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2017-11-06T22:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422703#M33841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting. The doubling of the single quotes seems to be QS trying to be helpful by escaping the single quotes. I can reproduce your example and problem in QS Desktop Sept 2017.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET does not do evaluation as LET does, but it does do DSE (substitution for $()).&amp;nbsp; I note your use of " around your set values.&amp;nbsp; The doc is unclear on this. It's shown in the examples with no explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However...SET is very greedy, it will grab everything up to the semicolon. I never use quotes around my string regardless of it's contents.&amp;nbsp; So you can code your statements like this without the outside quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_uptime = Sum({&amp;lt;Status={'Running'}&amp;gt;} m_minutes); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_plannedUptime = Sum({&amp;lt;Status-={'Planned Down'}&amp;gt;} m_minutes); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Set v_availability = $(v_uptime) / $(v_plannedUptime);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives the desired result in both QV and QS. &lt;/P&gt;&lt;P&gt;&lt;IMG alt="2017-11-06_17-59-25.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/182301_2017-11-06_17-59-25.png" style="height: 101px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2017 23:01:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422703#M33841</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2017-11-06T23:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Nested variables are broken?</title>
      <link>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422704#M33842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, that did it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I experimented a bit.&amp;nbsp; Here is a summary of when it is ok to put quotes around set statement variable declarations that contain other variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Wrapper&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;QS Desktop&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;QS Server&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;'single quotes'&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;not ok&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;not ok&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;"double quotes"&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ok&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;not ok&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;nothing&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ok&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ok&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Nov 2017 16:34:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Nested-variables-are-broken/m-p/1422704#M33842</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2017-11-07T16:34:13Z</dc:date>
    </item>
  </channel>
</rss>

