<?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 Variables (with SA) declaration from excel file in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824758#M290517</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi fellow Developers&lt;/P&gt;&lt;P&gt;I have struggled for some time now to find the best way to declare my variables i use for expressions in an excel workbook. I have issues with some expressions that includes some Set Analysis, for example;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="458"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="458"&gt;median({$&amp;lt;Dim1 = {'C'}, Dim2 = {"$(=maxstring(Dim2))"}&amp;gt;} Expression1)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im trying to declare a variable (using LET) but the Dim2 Set Analysis part fails and the end-result looks like;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 458px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="458"&gt;median({$&amp;lt;Dim1 = {'C'}, Dim2 = {""}&amp;gt;} Expression1)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would rather now have to type the variables in Excel using other characters than "(", ")", "'" and "i".&lt;/P&gt;&lt;P&gt;Have anyone found a good way to do this or is the best way to declare them in the GUI (ctrl+alt+v) and then create a macro that replaces some characters and store them in excel and a load script that replaces the replaced characters with the correct ones?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Until I find a good way without to many replace() functions when declaring the variables i guess the best way is to only delcare the variables in the GUI and just have an excel file with all variables as a backup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Nov 2014 13:18:05 GMT</pubDate>
    <dc:creator>blaise</dc:creator>
    <dc:date>2014-11-26T13:18:05Z</dc:date>
    <item>
      <title>Variables (with SA) declaration from excel file</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824758#M290517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi fellow Developers&lt;/P&gt;&lt;P&gt;I have struggled for some time now to find the best way to declare my variables i use for expressions in an excel workbook. I have issues with some expressions that includes some Set Analysis, for example;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="458"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="458"&gt;median({$&amp;lt;Dim1 = {'C'}, Dim2 = {"$(=maxstring(Dim2))"}&amp;gt;} Expression1)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im trying to declare a variable (using LET) but the Dim2 Set Analysis part fails and the end-result looks like;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 458px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD height="19" width="458"&gt;median({$&amp;lt;Dim1 = {'C'}, Dim2 = {""}&amp;gt;} Expression1)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would rather now have to type the variables in Excel using other characters than "(", ")", "'" and "i".&lt;/P&gt;&lt;P&gt;Have anyone found a good way to do this or is the best way to declare them in the GUI (ctrl+alt+v) and then create a macro that replaces some characters and store them in excel and a load script that replaces the replaced characters with the correct ones?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Until I find a good way without to many replace() functions when declaring the variables i guess the best way is to only delcare the variables in the GUI and just have an excel file with all variables as a backup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 13:18:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824758#M290517</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2014-11-26T13:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Variables (with SA) declaration from excel file</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824759#M290518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I use an excel sheet to define variables, but I don't know if this is exactly what you mean.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My excel sheet contains 3 culmns: variable name, variable definition and a description (last one is not necessary, for documentation purpose only).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following script reads the Excel sheet and defines al variables it finds:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14170082039539959" jivemacro_uid="_14170082039539959"&gt;
&lt;P&gt;// Script used to load standard variables from an excel sheet&lt;/P&gt;
&lt;P&gt;// Can be used to re-use variable definitions and standard formulas&lt;/P&gt;
&lt;P&gt;// The excel sheet used is 'QlikviewVariables.xls'&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;QV_variables:&lt;/P&gt;
&lt;P&gt;LOAD Name, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expression, &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description&lt;/P&gt;
&lt;P&gt;FROM&lt;/P&gt;
&lt;P&gt;'..\Scripts\QlikviewVariables.xls'&lt;/P&gt;
&lt;P&gt;(biff, embedded labels, table is QV_variables$);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Let vCount = NumMax(NoOfRows('QV_variables'),0)-1;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;FOR i=0 to vCount&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Let TempVarName = peek('Name',$(i),'QV_variables');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Let TempVarValue = peek('Expression',$(i),'QV_variables');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Let $(TempVarName) = '$(TempVarValue)';&lt;/P&gt;
&lt;P&gt;NEXT&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;//cleanup&lt;/P&gt;
&lt;P&gt;Set vCount = ;&lt;/P&gt;
&lt;P&gt;Set TempVarName = ;&lt;/P&gt;
&lt;P&gt;Set TempVarValue = ;&lt;/P&gt;
&lt;P&gt;Set i = ;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;DROP Table QV_variables;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 13:23:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824759#M290518</guid>
      <dc:creator />
      <dc:date>2014-11-26T13:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Variables (with SA) declaration from excel file</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824760#M290519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does mine expression (or a similiar one) works with your code? I'm having issues with my set analysis max filter. When I do a peek to store the variable everything between the two " is removed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 14:18:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824760#M290519</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2014-11-26T14:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Variables (with SA) declaration from excel file</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824761#M290520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The method from &lt;A href="https://community.qlik.com/qlik-users/73334"&gt;Dick Zeeman&lt;/A&gt; worked with SA expressions, too. Alternatively have a look here: &lt;A href="https://community.qlik.com/message/358055"&gt;Re: Setting a variable in script...&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 14:25:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824761#M290520</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2014-11-26T14:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Variables (with SA) declaration from excel file</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824762#M290521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Found the issue with my code!&lt;/P&gt;&lt;P&gt;I was doing one peek() to fetch the variable Name and then one more peek() to fetch the Variable Expression/Declaration string. This was followed by the actual variable declaration;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let '$(vVarName)' = '$(vVarExp)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By doing the peek() to fetch the variable expression when declaring the variable i got it to work;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;Variables:&lt;/P&gt;
&lt;P&gt;LOAD &lt;/P&gt;
&lt;P&gt;&amp;nbsp; varName, &lt;/P&gt;
&lt;P&gt;&amp;nbsp; varExp&lt;/P&gt;
&lt;P&gt;FROM&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [variables.xlsx]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (ooxml, embedded labels, table is Sheet1)&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for i = 0 to noofRows('variables') - 1&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; let vVarName = peek('varName',$(i),'variables');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; let '$(vVarName)' = peek('varExp',$(i),'variables'); // &amp;lt;-- this one works!&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Let vVarExp = peek('varExp',$(i),'variables'); // &amp;lt;-- this one does not!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; let '$(vVarName)' = '$(vVarExp)';&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;next i;&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the replies!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Nov 2014 15:03:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-with-SA-declaration-from-excel-file/m-p/824762#M290521</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2014-11-26T15:03:52Z</dc:date>
    </item>
  </channel>
</rss>

