<?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 Problem With Prior N Months Expression Using Only and Autonumber in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-With-Prior-N-Months-Expression-Using-Only-and-Autonumber/m-p/349052#M1171452</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to be able to sum sales over rolling quarters and rolling 12 months when user selects one month.&amp;nbsp; I understood that I could use autonumber on my date dimension to generate numbers to use for this.&amp;nbsp;&amp;nbsp; Alas, if I don't cross a year boundary, I can get an expression that calculates fine using the month number field which is loaded (sorted) directly from sql server.&amp;nbsp; However, when apply the same technique to a field generated by autonumber it does not work.&amp;nbsp; I just get the sales for the currently selected month. I have reduced the problem to just the currently selected month and the prior month for simplicity and formulated inline loads for completeness.&amp;nbsp; A basic .qvw file is attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My expressions are: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum( {$&amp;lt;[YearMonthNumber]+={ $(#=Only([YearMonthNumber])-1) }&amp;gt;} [Amount] )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // does not work&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum( {$&amp;lt;[MonthOfYear]+={ $(#=Only([MonthOfYear])-1) }&amp;gt;} [Amount] )&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;&amp;nbsp; // works&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My load script is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[Date]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Load &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Year, MonthOfYear, YearMonth,&amp;nbsp; autonumber(YearMonth) as YearMonthNumber;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;load * inline [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Year, MonthOfYear, YearMonth&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,6,'2011-06'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,7,'2011-07'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,8,'2011-08'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[Sales]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;load * Inline [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;YearMonth, Amount&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-06',10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-07',10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-08',10];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attached dashboard shows that the YearMonthNumber is being generated as I anticipated.&amp;nbsp; Output from table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="556"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="104"&gt;MonthOfYear&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="69"&gt;Year&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="67"&gt;YearMonth&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="112"&gt;YearMonthNumber&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="204"&gt;Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-06&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;7&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-07&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;8&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-08&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that my autonumber generated field (YearMonthNumber) is right justified whereas the MonthOfYear is left justified.&amp;nbsp; Not sure this is significant.&amp;nbsp;&amp;nbsp; I have displayed the value of '&lt;SPAN style="font-family: 'courier new', courier;"&gt;$(#=Only([YearMonthNumber])-1&lt;/SPAN&gt;' and it looks fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using QlikView 11.00.11282.0 SR1 64bit.&amp;nbsp;&amp;nbsp; Many thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bredon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jun 2012 13:28:58 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-06-12T13:28:58Z</dc:date>
    <item>
      <title>Problem With Prior N Months Expression Using Only and Autonumber</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-With-Prior-N-Months-Expression-Using-Only-and-Autonumber/m-p/349052#M1171452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to be able to sum sales over rolling quarters and rolling 12 months when user selects one month.&amp;nbsp; I understood that I could use autonumber on my date dimension to generate numbers to use for this.&amp;nbsp;&amp;nbsp; Alas, if I don't cross a year boundary, I can get an expression that calculates fine using the month number field which is loaded (sorted) directly from sql server.&amp;nbsp; However, when apply the same technique to a field generated by autonumber it does not work.&amp;nbsp; I just get the sales for the currently selected month. I have reduced the problem to just the currently selected month and the prior month for simplicity and formulated inline loads for completeness.&amp;nbsp; A basic .qvw file is attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My expressions are: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum( {$&amp;lt;[YearMonthNumber]+={ $(#=Only([YearMonthNumber])-1) }&amp;gt;} [Amount] )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // does not work&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum( {$&amp;lt;[MonthOfYear]+={ $(#=Only([MonthOfYear])-1) }&amp;gt;} [Amount] )&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;&amp;nbsp; // works&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My load script is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[Date]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Load &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Year, MonthOfYear, YearMonth,&amp;nbsp; autonumber(YearMonth) as YearMonthNumber;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;load * inline [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Year, MonthOfYear, YearMonth&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,6,'2011-06'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,7,'2011-07'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;2011,8,'2011-08'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[Sales]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;load * Inline [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;YearMonth, Amount&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-06',10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-07',10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'2011-08',10];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attached dashboard shows that the YearMonthNumber is being generated as I anticipated.&amp;nbsp; Output from table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="556"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="104"&gt;MonthOfYear&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="69"&gt;Year&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="67"&gt;YearMonth&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="112"&gt;YearMonthNumber&lt;/TD&gt;&lt;TD class="xl63" style="border-left: none;" width="204"&gt;Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;6&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-06&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;7&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-07&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;8&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;2011-08&lt;/TD&gt;&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that my autonumber generated field (YearMonthNumber) is right justified whereas the MonthOfYear is left justified.&amp;nbsp; Not sure this is significant.&amp;nbsp;&amp;nbsp; I have displayed the value of '&lt;SPAN style="font-family: 'courier new', courier;"&gt;$(#=Only([YearMonthNumber])-1&lt;/SPAN&gt;' and it looks fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using QlikView 11.00.11282.0 SR1 64bit.&amp;nbsp;&amp;nbsp; Many thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bredon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 13:28:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-With-Prior-N-Months-Expression-Using-Only-and-Autonumber/m-p/349052#M1171452</guid>
      <dc:creator />
      <dc:date>2012-06-12T13:28:58Z</dc:date>
    </item>
  </channel>
</rss>

