<?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 BUG: using variables in auto calendar in Archived Groups</title>
    <link>https://community.qlik.com/t5/Archived-Groups/BUG-using-variables-in-auto-calendar/m-p/2103433#M3900</link>
    <description>&lt;P&gt;Before February 2023, the auto calendar code for one app worked as expected, but after one update in the system it stopped giving the desired result in one of the fields. After some research, I've found the issue is the usage of a variable inside the auto calendar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We have one variable to know when the app was opened:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;let vL.ReferenceDate = monthstart(today(2));&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The variable is later used to calculate the offset of FY:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;year(yearstart(($1), 0, 4)) - year(yearstart((vL.ReferenceDate), 0, 4)) as FY_offset&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The workaround for the issue was to remove the variable and do a direct calculation of the date:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(year(yearstart(($1), 0, 4)) - year(yearstart(monthstart(today(2)), 0, 4))) as FY_offset,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though this works now, there's another case with the same issue where&amp;nbsp;&lt;SPAN&gt; we need the latest date of the data which we peek from another table:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Last_Date:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monthstart(date(max(invoice_mth))) as MAX_DATE &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Resident REVENUE;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;LET vMAX_invoice_mth = peek('MAX_DATE', 0, Last_Date);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Unfortunately, we can’t replace the variable with calculation directly as Qlik can’t use peek function there, so the workaround doesn't work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any idea of why this is happening? Code for the auto cal is attached.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jul 2025 14:48:52 GMT</pubDate>
    <dc:creator>SebastianCA</dc:creator>
    <dc:date>2025-07-23T14:48:52Z</dc:date>
    <item>
      <title>BUG: using variables in auto calendar</title>
      <link>https://community.qlik.com/t5/Archived-Groups/BUG-using-variables-in-auto-calendar/m-p/2103433#M3900</link>
      <description>&lt;P&gt;Before February 2023, the auto calendar code for one app worked as expected, but after one update in the system it stopped giving the desired result in one of the fields. After some research, I've found the issue is the usage of a variable inside the auto calendar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;We have one variable to know when the app was opened:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;let vL.ReferenceDate = monthstart(today(2));&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The variable is later used to calculate the offset of FY:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;year(yearstart(($1), 0, 4)) - year(yearstart((vL.ReferenceDate), 0, 4)) as FY_offset&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The workaround for the issue was to remove the variable and do a direct calculation of the date:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(year(yearstart(($1), 0, 4)) - year(yearstart(monthstart(today(2)), 0, 4))) as FY_offset,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though this works now, there's another case with the same issue where&amp;nbsp;&lt;SPAN&gt; we need the latest date of the data which we peek from another table:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Last_Date:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Load&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;monthstart(date(max(invoice_mth))) as MAX_DATE &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Resident REVENUE;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;LET vMAX_invoice_mth = peek('MAX_DATE', 0, Last_Date);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Unfortunately, we can’t replace the variable with calculation directly as Qlik can’t use peek function there, so the workaround doesn't work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Any idea of why this is happening? Code for the auto cal is attached.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 14:48:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Archived-Groups/BUG-using-variables-in-auto-calendar/m-p/2103433#M3900</guid>
      <dc:creator>SebastianCA</dc:creator>
      <dc:date>2025-07-23T14:48:52Z</dc:date>
    </item>
  </channel>
</rss>

