<?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: Why does a variable work sometimes but not all the time? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678348#M246077</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;probably because you sometimes have no records where DateID=today();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;your code seems to calculating the year of today&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;how about just doing this and save the trouble&amp;nbsp; ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LET vCurrentFY = Year(Today());&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Oct 2014 17:30:17 GMT</pubDate>
    <dc:creator>JonnyPoole</dc:creator>
    <dc:date>2014-10-22T17:30:17Z</dc:date>
    <item>
      <title>Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678343#M246072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to be a strange problem.&amp;nbsp; I have a variable that works or populates a value sometimes but other times it does not when I reload.&amp;nbsp; It seems random. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code to declare the variable:&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;&amp;nbsp; load&lt;/P&gt;&lt;P&gt;&amp;nbsp; max(Year) as CFY&lt;/P&gt;&lt;P&gt;&amp;nbsp; Resident MasterCalendar&lt;/P&gt;&lt;P&gt;&amp;nbsp; where DateID=today();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LET vCurrentFY = peek('CFY',0,'Temp'); &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table Temp;&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The vCurrentFY ties the correct year to each product in the data model:&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;FY as Product_Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='CY', ProductID&amp;amp;'_'&amp;amp;($(&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='LY', ProductID&amp;amp;'_'&amp;amp;($(&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)-1),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='2LY', ProductID&amp;amp;'_'&amp;amp;($(&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)-2)))) as Product_Year_Key&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone else experienced something like this?&amp;nbsp; If so, can you help me correct it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 14:56:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678343#M246072</guid>
      <dc:creator />
      <dc:date>2014-10-22T14:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678344#M246073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would check the log to verify Temp table has returned any rows, and if it does, check when $(&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;) is empty in the rest of the log (seaching for "ProductID&amp;amp;'_'&amp;amp;()") to retrieve any tips on what is happening.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 15:04:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678344#M246073</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2014-10-22T15:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678345#M246074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agree with Ruben, consider passing your table name 'temp' to this handy table function to see if there are any rows returned from the inital data load from the master calendar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;SPAN class="Bold" style="font-size: 10pt; line-height: 1.5em;"&gt;NoOfRows(&lt;/SPAN&gt;&lt;SPAN class="Italic" style="font-size: 10pt; line-height: 1.5em;"&gt;'Temp'&lt;/SPAN&gt;&lt;SPAN class="Bold" style="font-size: 10pt; line-height: 1.5em;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold" style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Bold" style="font-size: 10pt; line-height: 1.5em;"&gt;If there are 0, then you may need to set your variable differently.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 15:12:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678345#M246074</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-10-22T15:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678346#M246075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like this&lt;/P&gt;&lt;P&gt;FY as Product_Year,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='CY', ProductID&amp;amp;'_'&amp;amp;($(=&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='LY', ProductID&amp;amp;'_'&amp;amp;($(=&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)-1),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(FY='2LY', ProductID&amp;amp;'_'&amp;amp;($(=&lt;STRONG&gt;vCurrentFY&lt;/STRONG&gt;)-2)))) as Product_Year_Key&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 15:24:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678346#M246075</guid>
      <dc:creator />
      <dc:date>2014-10-22T15:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678347#M246076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&amp;nbsp; It looks like the Temp table is not returning any rows. Do you know why that would be happening?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 17:18:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678347#M246076</guid>
      <dc:creator />
      <dc:date>2014-10-22T17:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678348#M246077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;probably because you sometimes have no records where DateID=today();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;your code seems to calculating the year of today&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;how about just doing this and save the trouble&amp;nbsp; ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LET vCurrentFY = Year(Today());&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 17:30:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678348#M246077</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-10-22T17:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Why does a variable work sometimes but not all the time?</title>
      <link>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678349#M246078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect!&amp;nbsp; that seems to have worked.&amp;nbsp; I just removed the Temp Table all together and just declared my variable as you stated.&amp;nbsp; After the reload everything looks good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Oct 2014 17:41:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Why-does-a-variable-work-sometimes-but-not-all-the-time/m-p/678349#M246078</guid>
      <dc:creator />
      <dc:date>2014-10-22T17:41:15Z</dc:date>
    </item>
  </channel>
</rss>

