<?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 Set Year Variable in Load Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322173#M706337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a QVW wherein several objects use one of three variables either when displaying information or when calculating expressions:&lt;/P&gt;&lt;P&gt;1. vYear_Current&lt;/P&gt;&lt;P&gt;2. vYear_Previous&lt;/P&gt;&lt;P&gt;3. vYear_PreviousX2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to have these variables set to the appropriate values when data is loaded into the file. For example, if I loaded data today I would want:&lt;/P&gt;&lt;P&gt;vYear_Current = "2012"&lt;/P&gt;&lt;P&gt;vYear_Previous = "2011"&lt;/P&gt;&lt;P&gt;vYear_PreviousX2 = "2010"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using the following in my load script but it did not work:&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now());&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now(-1));&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now(-2));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jan 2012 17:35:31 GMT</pubDate>
    <dc:creator>jcampbell</dc:creator>
    <dc:date>2012-01-31T17:35:31Z</dc:date>
    <item>
      <title>Set Year Variable in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322173#M706337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a QVW wherein several objects use one of three variables either when displaying information or when calculating expressions:&lt;/P&gt;&lt;P&gt;1. vYear_Current&lt;/P&gt;&lt;P&gt;2. vYear_Previous&lt;/P&gt;&lt;P&gt;3. vYear_PreviousX2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to have these variables set to the appropriate values when data is loaded into the file. For example, if I loaded data today I would want:&lt;/P&gt;&lt;P&gt;vYear_Current = "2012"&lt;/P&gt;&lt;P&gt;vYear_Previous = "2011"&lt;/P&gt;&lt;P&gt;vYear_PreviousX2 = "2010"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried using the following in my load script but it did not work:&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now());&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now(-1));&lt;/P&gt;&lt;P&gt;SET vYear_Current = YEAR(now(-2));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 17:35:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322173#M706337</guid>
      <dc:creator>jcampbell</dc:creator>
      <dc:date>2012-01-31T17:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Set Year Variable in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322174#M706339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the following instead. LET evaluates the function, then stores into the variable. SET only stores.&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"&gt;&lt;P&gt;LET vYear_Current = Year(Today());&lt;/P&gt;&lt;P&gt;LET vYear_Current = Year(Today()) -1;&lt;/P&gt;&lt;P&gt;LET vYear_Current = Year(Today()) -2;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jan 2012 17:53:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322174#M706339</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-01-31T17:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set Year Variable in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322175#M706341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, If I Want the months of this year it would be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;LET vYear_Current = Year(Month((Today())); Jun&lt;BR /&gt;LET vYear_Current = Year(Month(Today())) -1; May&lt;BR /&gt;LET vYear_Current = Year(Month(Today())) -2; Apr&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;Thanks,&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jun 2012 13:41:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322175#M706341</guid>
      <dc:creator>pgalvezt</dc:creator>
      <dc:date>2012-06-14T13:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: Set Year Variable in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322176#M706343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd rather use complete dates or at least, month date combination, as long as you already have a field with the same format in your calendar:&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_13396814315051385" jivemacro_uid="_13396814315051385"&gt;&lt;P&gt;LET vCurrentMonth = MonthName(Today());&lt;/P&gt;&lt;P&gt;LET vPreviousMonth = MonthName(AddMonths(Today(), -1));&lt;/P&gt;&lt;P&gt;LET vPrePreviousMonth = &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;MonthName(AddMonths(Today(), -2));&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As mentioned, you need a field in your calendar built with MonthName.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.: Please next time open a new thread, this one was closed six months ago.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jun 2012 13:44:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Year-Variable-in-Load-Script/m-p/322176#M706343</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-06-14T13:44:59Z</dc:date>
    </item>
  </channel>
</rss>

