<?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: Create a variable for code based on selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095145#M363872</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This way you can't pass your selection to script (during load). Instead of loading the expressions, define variables in the front-end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jan 2016 05:19:23 GMT</pubDate>
    <dc:creator>tresB</dc:creator>
    <dc:date>2016-01-15T05:19:23Z</dc:date>
    <item>
      <title>Create a variable for code based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095144#M363871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am hoping to create a variable that I can use multiple times in a code.&amp;nbsp; It should be based on a selection of a list box.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, I created a list box called Age_Group.&amp;nbsp; When the user selects '30-39' in the Age_Group box, I want string '30-39' to be put in the equations below in the place of the variable vAge.&amp;nbsp; Below is the code that I tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: blue; font-size: 9pt; font-family: 'Courier New';"&gt;set&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #222222; font-family: Calibri, sans-serif; font-size: 14.6667px;"&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;vAge&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: maroon;"&gt;[Age_Group]&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt;;&lt;BR /&gt;&lt;BR /&gt;Expression:&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: blue; font-size: 9pt; font-family: 'Courier New';"&gt;load&lt;/STRONG&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: blue;"&gt;inline&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: maroon;"&gt;[&lt;BR /&gt;Expression, Exp&lt;BR /&gt;'Medical Incurred', sum({&amp;lt;Age_Group= {$(vAge)}&amp;gt;} T_ITD_INCRD_MED_AMT)/sum(total &amp;lt;Accident_Year&amp;gt; T_ITD_INCRD_MED_AMT)&lt;BR /&gt;'Indemnity Incurred', sum(&amp;lt;Age_Group&amp;gt; T_ITD_INCRD_INDM_AMT)/sum(total &amp;lt;Accident_Year&amp;gt; T_ITD_INCRD_INDM_AMT)&lt;BR /&gt;'Indemnity Paid', sum({&amp;lt;Age_Group= {$(vAge)}&amp;gt;} T_ITD_PD_INDM_AMT)/sum(total &amp;lt;Accident_Year&amp;gt; T_ITD_PD_INDM_AMT)&lt;BR /&gt;]&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Side note: I am already taking 2 different list boxes into account when creating these equations, hence why I already used the load inline statements.&amp;nbsp; I am open to any other suggestions that involve taking several fields.&amp;nbsp; It gets a bit complicated when looking at percentages of a whole set number.&amp;nbsp; I'm trying my best at learning set analysis &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9pt; font-family: 'Courier New'; color: black;"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Thanks for any help you can provide!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 03:10:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095144#M363871</guid>
      <dc:creator />
      <dc:date>2016-01-15T03:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable for code based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095145#M363872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This way you can't pass your selection to script (during load). Instead of loading the expressions, define variables in the front-end.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 05:19:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095145#M363872</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2016-01-15T05:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable for code based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095146#M363873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your response!&amp;nbsp; Can you please clarify what you mean?&amp;nbsp; I tried moving the &lt;STRONG style="color: #0000ff; font-family: Courier New;"&gt;set&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 9pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #222222; font-family: Calibri, sans-serif; font-size: 14.66px;"&gt;&lt;EM style="color: gray; font-family: 'Courier New'; font-size: 9pt;"&gt;vAge&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 9pt;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: maroon; font-family: 'Courier New'; font-size: 9pt;"&gt;[Age_Group]&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-size: 9pt;"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;to the very beginning of the script, but this didn't seem to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 18:36:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095146#M363873</guid>
      <dc:creator />
      <dc:date>2016-01-15T18:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable for code based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095147#M363874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Open your application-&amp;gt; press Ctrl+Alt+V , you would get the variable overview window where you can define variables in the front-end. The variavles defined in here, are responsive to selection.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 06:06:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095147#M363874</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2016-01-18T06:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create a variable for code based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095148#M363875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, this worked!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It didn't end up working in the inline statement like I had above, so instead I used conditional hide/ unhide under expressions.&amp;nbsp; For anyone's reference, I used this equation:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Age_Group&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;= {'$(vAge)'}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;T_ITD_INCRD_INDM_AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;T_ITD_INCRD_INDM_AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 13:07:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-a-variable-for-code-based-on-selection/m-p/1095148#M363875</guid>
      <dc:creator />
      <dc:date>2016-01-20T13:07:11Z</dc:date>
    </item>
  </channel>
</rss>

