<?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: Setting a variable to select an item from a field in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-to-select-an-item-from-a-field/m-p/1034118#M939500</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try without dollar sign expansion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=If(Only(Scenario) = vLastYear, ....)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Feb 2016 17:21:50 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-02-02T17:21:50Z</dc:date>
    <item>
      <title>Setting a variable to select an item from a field</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-to-select-an-item-from-a-field/m-p/1034117#M939499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am fairly new to QlikView and do not have much experience with Variables so any help is welcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my QlikView report is a field which outlines the scenario i.e. Budget, Actual, Actual 15 for the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately data that relates to last year is pulling in as scenario 'Actual 15'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having to complete set analysis to pull the data that I need and I would prefer to use a variable for 'LastYear' that I can set to 'Actual 15' but can amend next year to 'Actual 16'.&amp;nbsp; Otherwise I will need to amend all of the formulas that I have written (about thirty!) when the year rolls over. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have set the following variable but do not think that it is right.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;vLastYear&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)='Actual 15' &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following formula works for 'Actual 15'&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//IF Scenario is Actual 15&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)='Actual 15',&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//THEN select Actual but with the NominalPeriodYear as selection but plus 1 (the year will be showing as 2015)&lt;BR /&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;NominalPeriodYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=Only(NominalPeriodYear)+1)&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={Actual}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;),&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//ELSE Sum the value for Actual and the year selected 2016&lt;BR /&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;Scenario&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={Actual}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Value&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)))) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;If the&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt;"&gt;variable is set correctly then how do I get it to be recognised in the formula.&amp;nbsp; I have tried &lt;SPAN style="color: #008000;"&gt; &lt;/SPAN&gt;((&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;Only&lt;/SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 10pt;"&gt;Scenario&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;)=$(vLastYear).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2016 17:06:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-to-select-an-item-from-a-field/m-p/1034117#M939499</guid>
      <dc:creator />
      <dc:date>2016-02-02T17:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a variable to select an item from a field</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-a-variable-to-select-an-item-from-a-field/m-p/1034118#M939500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try without dollar sign expansion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=If(Only(Scenario) = vLastYear, ....)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2016 17:21:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-a-variable-to-select-an-item-from-a-field/m-p/1034118#M939500</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-02-02T17:21:50Z</dc:date>
    </item>
  </channel>
</rss>

