<?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 6 Weeks in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410863#M488332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a serial weeknumber in the script using the rowno() function. You can use the serial weeknumber instead of the original weeknumber. I don't know your data model, so I can't tell if you can use the rowno() directly on your source table or if you need to create a separate week table first with something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Weeks:&lt;/P&gt;&lt;P&gt;load distinct &lt;/P&gt;&lt;P&gt;rowno() as serialweek,&lt;/P&gt;&lt;P&gt; week &amp;amp; '-' &amp;amp; year as week-year,&lt;/P&gt;&lt;P&gt;from ...sourcetable... ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create the week-year field in your source table too to associate the two tables&lt;/P&gt;&lt;P&gt;Your set analysis expression would become something like this I think:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;avg&lt;/P&gt;&lt;P&gt;({&amp;lt;KPI={"Total stock"},Week={"YTD"}&amp;gt; +&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;lt;KPI={"Total stock"},Year=,Week=,serialweek={"&amp;gt;=$(=max(serialweek)-5)&amp;lt;=$(=max(serialweek))"}&amp;gt;} &lt;/P&gt;&lt;P&gt; Data)&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jan 2013 10:17:32 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2013-01-10T10:17:32Z</dc:date>
    <item>
      <title>Previous 6 Weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410862#M488331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have encountered an issue at year end in relation to a variable and set analysis that I currently have. I have a set analysis that uses a variable which looks at data for the current week as well as the last 6 weeks worth of data, the original requirement was to look at a year at a time so the below expression worked fine as it simply looked at e.g. week 46, week 46 -1, week 46 -2, etc. However a new requirement is to look at data across multiple years which proves problematic at the start of a new year as the current variable will not take into account the previous years last few weeks. The only date information I have is week and year (not a specific date) so I was thinking that a numeric value should be attached to the week-year so that a week-year, week-year -1, week-year -2 would work. Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ralph&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;avg&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;KPI&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"Total stock"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;},&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Week&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"YTD"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=vCurrentWeek)&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=(vCurrentWeek-2))&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=(vCurrentWeek-3))&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=(vCurrentWeek-4))&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=(vCurrentWeek-5))&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;$(=(vCurrentWeek-1))&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Data&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 10:00:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410862#M488331</guid>
      <dc:creator />
      <dc:date>2013-01-10T10:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 6 Weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410863#M488332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create a serial weeknumber in the script using the rowno() function. You can use the serial weeknumber instead of the original weeknumber. I don't know your data model, so I can't tell if you can use the rowno() directly on your source table or if you need to create a separate week table first with something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Weeks:&lt;/P&gt;&lt;P&gt;load distinct &lt;/P&gt;&lt;P&gt;rowno() as serialweek,&lt;/P&gt;&lt;P&gt; week &amp;amp; '-' &amp;amp; year as week-year,&lt;/P&gt;&lt;P&gt;from ...sourcetable... ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create the week-year field in your source table too to associate the two tables&lt;/P&gt;&lt;P&gt;Your set analysis expression would become something like this I think:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;avg&lt;/P&gt;&lt;P&gt;({&amp;lt;KPI={"Total stock"},Week={"YTD"}&amp;gt; +&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;lt;KPI={"Total stock"},Year=,Week=,serialweek={"&amp;gt;=$(=max(serialweek)-5)&amp;lt;=$(=max(serialweek))"}&amp;gt;} &lt;/P&gt;&lt;P&gt; Data)&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 10:17:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410863#M488332</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-01-10T10:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 6 Weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410864#M488333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, that is useful although I don't think it will work in this case. The datasource is a crosstable from Excel and is over 2 sheets so each actual week might have 100's of rows worth of data and the rowno() will obviously replicate this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 11:13:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410864#M488333</guid>
      <dc:creator />
      <dc:date>2013-01-10T11:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 6 Weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410865#M488334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's why I mentioned you might have to create a separate weeks table. The load &lt;STRONG&gt;distinct &lt;/STRONG&gt;will create only one record per week, so rowno() can create a serialweek field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 12:39:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410865#M488334</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-01-10T12:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Previous 6 Weeks</title>
      <link>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410866#M488335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had to use a different approach although I'll use the above approach in future projects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ralph &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 16:39:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Previous-6-Weeks/m-p/410866#M488335</guid>
      <dc:creator />
      <dc:date>2013-01-10T16:39:22Z</dc:date>
    </item>
  </channel>
</rss>

