<?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: Re: Mutant Variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785939#M278039</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IMHO this is a different problem. I read the first one as: "is there a method to get the object ID in an expression so that it can be adjusted according to the object where it is used". Don't know the answer to that. There is an (undocumented) function called GetActiveSheetId, maybe there is also one that returns the active object ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second question is about how to store expressions into variables for later use. You can do that like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vSaldo = '=IF ($' &amp;amp; '(vObjectID) = 1, &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) , &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-size: 8pt; font-family: 'courier new', courier;"&gt;sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; );';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to manipulate the content of this variable later on, you have to make sure that $-substitution is NOT performed on variable &lt;SPAN style="font-family: 'courier new', courier;"&gt;$(vObjectID)&lt;/SPAN&gt; in the script already. Otherwise your expression becomes broken.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A solution for that is to use another character instead of the dollar sign, and replace the replacement character during the very last assignment, e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vSaldo = '=IF (§(vObjectID) = 1, &lt;SPAN style="color: #3d3d3d;"&gt;sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) , &lt;SPAN style="color: #3d3d3d;"&gt;sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; );';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;LET vSaldo2 = '$(vSaldo)' &amp;amp; ' + 1000';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vTotal = Replace('$(vSaldo2)', '§', '$'); // No script manipulations anymore after this statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Dec 2014 16:44:36 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2014-12-05T16:44:36Z</dc:date>
    <item>
      <title>Mutant Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785935#M278035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everybody&lt;/P&gt;&lt;P&gt;I need to find a way to make a variable changes depending of the object in which this is deployed, &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.63636302948px;"&gt;The problem is that I need to use the same variable for different objects but these have different dimensions&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if( $(vObjectID)=1, // or something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt; sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 14:51:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785935#M278035</guid>
      <dc:creator />
      <dc:date>2014-12-05T14:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mutant Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785936#M278036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to 2 variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If just set expression is changing the following should do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(total $(var1)SALDO)&lt;/P&gt;&lt;P&gt;sum(total $(var2)SALDO)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:07:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785936#M278036</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-05T15:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Mutant Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785937#M278037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any specific reason why you cannot have customized expressions in different objects?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:12:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785937#M278037</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2014-12-05T15:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Mutant Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785938#M278038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The expession is into a variable in script and this is chained&amp;nbsp; many times with many others variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vSaldo = &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;if( $(vObjectID)=1, // or something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; );&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 12.7272720336914px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Let vTotal = $(vSaldo) + $(vOtherVariables); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 15:26:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785938#M278038</guid>
      <dc:creator />
      <dc:date>2014-12-05T15:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Mutant Variable</title>
      <link>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785939#M278039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IMHO this is a different problem. I read the first one as: "is there a method to get the object ID in an expression so that it can be adjusted according to the object where it is used". Don't know the answer to that. There is an (undocumented) function called GetActiveSheetId, maybe there is also one that returns the active object ID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second question is about how to store expressions into variables for later use. You can do that like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vSaldo = '=IF ($' &amp;amp; '(vObjectID) = 1, &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) , &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-size: 8pt; font-family: 'courier new', courier;"&gt;sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; );';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to manipulate the content of this variable later on, you have to make sure that $-substitution is NOT performed on variable &lt;SPAN style="font-family: 'courier new', courier;"&gt;$(vObjectID)&lt;/SPAN&gt; in the script already. Otherwise your expression becomes broken.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A solution for that is to use another character instead of the dollar sign, and replace the replacement character during the very last assignment, e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vSaldo = '=IF (§(vObjectID) = 1, &lt;SPAN style="color: #3d3d3d;"&gt;sum(total {$&amp;lt;FLAGP={1},&amp;nbsp; &amp;gt;}SALDO) , &lt;SPAN style="color: #3d3d3d;"&gt;sum(total &amp;lt;AnioMes&amp;gt; SALDO)&amp;nbsp; );';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 8pt;"&gt;LET vSaldo2 = '$(vSaldo)' &amp;amp; ' + 1000';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'courier new', courier;"&gt;LET vTotal = Replace('$(vSaldo2)', '§', '$'); // No script manipulations anymore after this statement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 16:44:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Mutant-Variable/m-p/785939#M278039</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2014-12-05T16:44:36Z</dc:date>
    </item>
  </channel>
</rss>

