<?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 Set Analysis and Point in time in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-Point-in-time/m-p/384829#M143772</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;In my application I have Sales data and a Master Calendar (containing all the usual Day, Month, Quarter etc) that is linked to the Sales table by a field called "Date".&lt;/P&gt;&lt;P&gt;I present to the user a listbox of &lt;STRONG&gt;MonthID&lt;/STRONG&gt;s and based on their selection I present some "point in time" statistics like "Month to date" "year to date" etc. This is achieved through the use of variable definitions such as in the following examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Example 1&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called &lt;STRONG&gt;vSetMTD&lt;/STRONG&gt; whose definition is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;{$&amp;lt;MonthID = {$(=Max(MonthID))},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Date = {"&amp;lt;=$(=Max(Date))"},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Year = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Quarter = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Period = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;[Period (#)] = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Month = &amp;gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; In my chart the expression would be simply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Sum($(vSetMTD) Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Example 2&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called &lt;STRONG&gt;vSetPreviousYearMTD&lt;/STRONG&gt; whose definition is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; {$&amp;lt;MonthID = {$(=Max(MonthID) - 12)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Date = {"&amp;lt;=$(=Date(MakeDate(Max(Year) - 1, Max([Month (#)]), Day(Max(Date))),'DD/MM/YYYY'))"},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Year = {$(=Max(Year)-1)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Quarter = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Period = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;[Period (#)] = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Month = &amp;gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my chart the expression would be simply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Sum($(vSetPreviousYearMTD) Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;QUESTION&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;I now need to extend the functionality to allow them to choose a range of months from the MonthID listbox and for my chart to show:&lt;/P&gt;&lt;P&gt;a) &lt;STRONG&gt;Sales for Selected Period:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; This is easy: it is simply &lt;SPAN style="color: #0000ff;"&gt;Sum(Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;b) &lt;STRONG&gt;Sales for Previous Period:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is based on the idea that if they chose 3 months (say MonthIDs &lt;STRONG&gt;12,13,14&lt;/STRONG&gt;) then the &lt;EM&gt;Previous Period&lt;/EM&gt; would be MonthIDs &lt;STRONG&gt;9, 10 and 11&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a variable definition (as those above) which defines the following logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MonthID &amp;gt;=&amp;nbsp; Min(MonthID) - (Max(MonthID) - Min(MonthID) + 1)&lt;/P&gt;&lt;P&gt;Date &amp;lt; MakeDate(Min(Year), Min(MonthNo), 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c) &lt;STRONG&gt;Sales for Selected Period Previous Year&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Same issue as above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached an example application thta can be "played with"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alexis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Sep 2012 10:04:13 GMT</pubDate>
    <dc:creator>alexis</dc:creator>
    <dc:date>2012-09-06T10:04:13Z</dc:date>
    <item>
      <title>Set Analysis and Point in time</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-and-Point-in-time/m-p/384829#M143772</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;In my application I have Sales data and a Master Calendar (containing all the usual Day, Month, Quarter etc) that is linked to the Sales table by a field called "Date".&lt;/P&gt;&lt;P&gt;I present to the user a listbox of &lt;STRONG&gt;MonthID&lt;/STRONG&gt;s and based on their selection I present some "point in time" statistics like "Month to date" "year to date" etc. This is achieved through the use of variable definitions such as in the following examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Example 1&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called &lt;STRONG&gt;vSetMTD&lt;/STRONG&gt; whose definition is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;{$&amp;lt;MonthID = {$(=Max(MonthID))},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Date = {"&amp;lt;=$(=Max(Date))"},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Year = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Quarter = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Period = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;[Period (#)] = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Month = &amp;gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; In my chart the expression would be simply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Sum($(vSetMTD) Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Example 2&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a variable called &lt;STRONG&gt;vSetPreviousYearMTD&lt;/STRONG&gt; whose definition is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; {$&amp;lt;MonthID = {$(=Max(MonthID) - 12)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Date = {"&amp;lt;=$(=Date(MakeDate(Max(Year) - 1, Max([Month (#)]), Day(Max(Date))),'DD/MM/YYYY'))"},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Year = {$(=Max(Year)-1)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Quarter = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Period = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;[Period (#)] = ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Month = &amp;gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my chart the expression would be simply:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Sum($(vSetPreviousYearMTD) Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;QUESTION&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;I now need to extend the functionality to allow them to choose a range of months from the MonthID listbox and for my chart to show:&lt;/P&gt;&lt;P&gt;a) &lt;STRONG&gt;Sales for Selected Period:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; This is easy: it is simply &lt;SPAN style="color: #0000ff;"&gt;Sum(Sales)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;b) &lt;STRONG&gt;Sales for Previous Period:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; This is based on the idea that if they chose 3 months (say MonthIDs &lt;STRONG&gt;12,13,14&lt;/STRONG&gt;) then the &lt;EM&gt;Previous Period&lt;/EM&gt; would be MonthIDs &lt;STRONG&gt;9, 10 and 11&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a variable definition (as those above) which defines the following logic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MonthID &amp;gt;=&amp;nbsp; Min(MonthID) - (Max(MonthID) - Min(MonthID) + 1)&lt;/P&gt;&lt;P&gt;Date &amp;lt; MakeDate(Min(Year), Min(MonthNo), 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c) &lt;STRONG&gt;Sales for Selected Period Previous Year&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Same issue as above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached an example application thta can be "played with"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanx in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alexis&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 10:04:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-and-Point-in-time/m-p/384829#M143772</guid>
      <dc:creator>alexis</dc:creator>
      <dc:date>2012-09-06T10:04:13Z</dc:date>
    </item>
  </channel>
</rss>

