<?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: Can I create a variable that holds another variable? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519180#M106193</link>
    <description>&lt;P&gt;You can avoid using the Replace by using peek to get the Def:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FOR i = 0 to NoOfRows('Variables')-1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; LET vVarname = peek('Varname',$(i),'Variables');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;STRONG&gt;LET $(vVarname)=peek('Varvalue',$(i),'Variables');&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NEXT i&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
    <pubDate>Tue, 27 May 2025 14:37:07 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2025-05-27T14:37:07Z</dc:date>
    <item>
      <title>Can I create a variable that holds another variable?</title>
      <link>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519136#M106182</link>
      <description>&lt;P&gt;I have a variable in the frontend, vMD which holds the =Max(Date).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It means I can do "Sum(If(Date = '$(vMD)', Value))" and that works great.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;What I'd really like to do though, is in the LOAD script, programmatically create lots of variables to hold measures. I actually want to create a SUB to be able to create these measures, but that's down the line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, I just need to be able to put something in the load script that says:&lt;/P&gt;&lt;P&gt;SET vNewVar = "&lt;SPAN&gt;Sum(If(Date = '$(vMD)', Value))";&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Such that in the frontend it works. I guess, what I want is to just store the TEXT, in pure TEXT form, so it appears AS I TYPE IT without doing any dollar expansion, such that in the frontend I can then use this text as the text for the measure.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But whatever I try, it evaluates the $(vMD) to nothing and fails. If I try concatenating bits of it together, it doesn't evaluate that concatenation, so I end up with&lt;BR /&gt;&lt;BR /&gt;'$' &amp;amp; (vMD)' &amp;amp; ', Value)'&amp;nbsp;&lt;/P&gt;&lt;P&gt;(or whatever) as the evaluation, rather than the concat.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It feels like this must be something people have tried to do before, but I can't find a good example. Any help massively appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 11:16:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519136#M106182</guid>
      <dc:creator>Richard_Norris</dc:creator>
      <dc:date>2025-05-27T11:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a variable that holds another variable?</title>
      <link>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519152#M106186</link>
      <description>&lt;P&gt;Some time ago I did few experiments, and I have written simple mechanism to create variables automatically.&lt;/P&gt;&lt;P&gt;It will not work with definitions written in Qlik script. You need excel file with 3 columns: name, definition and flag field fExpand.&lt;/P&gt;&lt;P&gt;The trick is to use replace() function, but first parameter is a variable name without expand (dollar sign), and two next parameters of replace() function has text which does not exists in definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;P&gt;variables:&lt;BR /&gt;LOAD&lt;BR /&gt;name,&lt;BR /&gt;"definition",&lt;BR /&gt;fExpand&lt;BR /&gt;FROM [lib://Data/vars.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for i = 0 to NoOfRows('variables')-1&lt;BR /&gt;let vSourceVarName = Peek('name', $(i), 'variables'); // name&lt;BR /&gt;let vSourceVarDef = Peek('definition', $(i), 'variables'); // definition&lt;BR /&gt;let vExpand = Peek('fExpand', $(i), 'variables'); // expand?&lt;BR /&gt;if vExpand = 0 then&lt;BR /&gt;let $(vSourceVarName) = '$(vSourceVarDef)';&lt;BR /&gt;else&lt;BR /&gt;let $(vSourceVarName) = replace(vSourceVarDef, 'blahblah', 'Blahblah'); // trick to not expand variable&lt;BR /&gt;endif&lt;BR /&gt;next i;&lt;/P&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope it will be helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 12:48:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519152#M106186</guid>
      <dc:creator>Adam_Romanowski</dc:creator>
      <dc:date>2025-05-27T12:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a variable that holds another variable?</title>
      <link>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519180#M106193</link>
      <description>&lt;P&gt;You can avoid using the Replace by using peek to get the Def:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FOR i = 0 to NoOfRows('Variables')-1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; LET vVarname = peek('Varname',$(i),'Variables');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;STRONG&gt;LET $(vVarname)=peek('Varvalue',$(i),'Variables');&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NEXT i&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 14:37:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519180#M106193</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2025-05-27T14:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Can I create a variable that holds another variable?</title>
      <link>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519615#M106296</link>
      <description>&lt;P&gt;Amazing, thanks so much guys! I used replace just because with how messy my formulas are, it's a bit easier to tell what's going on having it laid out in clearly labelled steps, but I'll bear that in mind for the future Rob!&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 15:01:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Can-I-create-a-variable-that-holds-another-variable/m-p/2519615#M106296</guid>
      <dc:creator>Richard_Norris</dc:creator>
      <dc:date>2025-05-30T15:01:17Z</dc:date>
    </item>
  </channel>
</rss>

