<?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: Previous 'n' months data calculation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302515#M1188032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The attached example lets you select what rolling period to use for each month using a slider.&amp;nbsp; The selection when it comes up includes 0, 1 and 2 months back, so it is a rolling 3 months average including the current month.&amp;nbsp; Want a rolling 12 months average?&amp;nbsp; Drag the right side of the slider over to 12.&amp;nbsp; Want to exclude the current month, so it's a rolling previous 12 months?&amp;nbsp; Drag the slider one to the right so you're including months 1-13 back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Aug 2011 23:37:46 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2011-08-26T23:37:46Z</dc:date>
    <item>
      <title>Previous 'n' months data calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302513#M1188030</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;My requirement is to show previous 'n' months data in a chart.&lt;/P&gt;&lt;P&gt;There should be a list box with choices as 1, 2, 3, ...10; and depending on user selection that much previous months data with respect to current date should get displayed.&lt;/P&gt;&lt;P&gt;I have read all posts about rolling 3 months or rolling 13 months data and that hardcoding works just fine.&lt;/P&gt;&lt;P&gt;But here I dont want to hardcode values, instead user should be able to select how many previous months data he wishes to see.&lt;/P&gt;&lt;P&gt;Please help me out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 06:46:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302513#M1188030</guid>
      <dc:creator />
      <dc:date>2011-08-26T06:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 'n' months data calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302514#M1188031</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;As always there is more than one way to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create two variables, ie &lt;SPAN style="font-family: courier new,courier;"&gt;vMonthsInput &lt;/SPAN&gt;and &lt;SPAN style="font-family: courier new,courier;"&gt;vCalculatedDate&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Create an Input Box for &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;vMonthsInput &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Add two event triggers on &lt;SPAN style="font-family: courier new,courier;"&gt;vMonthsInput&lt;/SPAN&gt;, one on &lt;SPAN style="font-family: courier new,courier;"&gt;OnChange &lt;/SPAN&gt;and one on &lt;SPAN style="font-family: courier new,courier;"&gt;OnInput&lt;/SPAN&gt;&lt;OL&gt;&lt;LI&gt;They should have the same action: "Set Variable" and you should set the variable &lt;SPAN style="font-family: courier new,courier;"&gt;vCalculatedDate &lt;/SPAN&gt;to: &lt;SPAN style="font-family: courier new,courier;"&gt;=AddMonths(today(),-&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;vMonthsInput &lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;)&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;LI&gt;Use this set expression in the chart: &lt;SPAN style="font-family: courier new,courier;"&gt;{&amp;lt;Date={"&amp;gt;$(vCalculatedDate)"}&amp;gt;}&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;This will select Dates that are within vMonthsInput months from today.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;If you want to select Dates starting from the first of the month that was x months before today, you have to adjust the calculation in 3.1 above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;hth/gg&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 07:24:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302514#M1188031</guid>
      <dc:creator>gandalfgray</dc:creator>
      <dc:date>2011-08-26T07:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 'n' months data calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302515#M1188032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The attached example lets you select what rolling period to use for each month using a slider.&amp;nbsp; The selection when it comes up includes 0, 1 and 2 months back, so it is a rolling 3 months average including the current month.&amp;nbsp; Want a rolling 12 months average?&amp;nbsp; Drag the right side of the slider over to 12.&amp;nbsp; Want to exclude the current month, so it's a rolling previous 12 months?&amp;nbsp; Drag the slider one to the right so you're including months 1-13 back.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 23:37:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302515#M1188032</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-26T23:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 'n' months data calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302516#M1188033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have personnel edition of qlikview, so I cannot open your file &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@GandalfGray,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently I am showing data on lat 13 Month's month end in chart. I want to make the number of months dynamic.&lt;/P&gt;&lt;P&gt;When I use calculations suggested by you with today() it just works fine. But when I use it with Max(Date), it displays nothing.&lt;/P&gt;&lt;P&gt;I want to use that calculation with Max(Date).&lt;/P&gt;&lt;P&gt;Also I am not much familier with adding events. Please help me out.&lt;/P&gt;&lt;P&gt;(In my database, date is in 'YYYY-MM-DD' format and I have qlikview 9.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 06:11:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302516#M1188033</guid>
      <dc:creator />
      <dc:date>2011-08-29T06:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 'n' months data calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302517#M1188034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;rohitsant87 wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have personnel edition of qlikview, so I cannot open your file&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, here's the script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;[Main]:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,date(monthstart(Date),'MMM YYYY') as MonthYear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;date(date#(20080101,'YYYYMMDD')+floor(rand()*1000)) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,ceil(rand()*100) as Revenue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE 500&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;[Date Linkage]:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD DISTINCT MonthYear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT [Main]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LEFT JOIN ([Date Linkage])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD MonthYear as AsOfMonthYear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT [Date Linkage]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;INNER JOIN ([Date Linkage])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD *&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,round((AsOfMonthYear-MonthYear)/30.436875) as MonthsBack&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT [Date Linkage]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHERE MonthYear &amp;lt;= AsOfMonthYear&lt;/SPAN&gt;&lt;BR /&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;For the chart:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Dimension&amp;nbsp; = AsOfMonthYear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Expression = sum(Revenue)/count(MonthsBack)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And beneath it there's a slider:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Field = MonthsBack&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Multi Value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Continuous/Numeric&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Static Step = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2011 15:39:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-n-months-data-calculation/m-p/302517#M1188034</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-29T15:39:53Z</dc:date>
    </item>
  </channel>
</rss>

