<?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 Selecting Latest 2 Quarters in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735316#M475130</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Eveyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 fields; Quarter which includes 1,2,3,4 and another field YEAR which includes YEAR. I want to use those 2 fields to get the data for the latest 2 quarters in charts which is 2014 Q1 and 2014 Q2 by using set analysis and this has to be dynamic, so when the new data populates for the new quarter which is 2014 Q3, the chart will show data for 2014 Q3 and 2014 Q2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Aug 2014 17:00:47 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-08-07T17:00:47Z</dc:date>
    <item>
      <title>Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735316#M475130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Eveyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 2 fields; Quarter which includes 1,2,3,4 and another field YEAR which includes YEAR. I want to use those 2 fields to get the data for the latest 2 quarters in charts which is 2014 Q1 and 2014 Q2 by using set analysis and this has to be dynamic, so when the new data populates for the new quarter which is 2014 Q3, the chart will show data for 2014 Q3 and 2014 Q2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 17:00:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735316#M475130</guid>
      <dc:creator />
      <dc:date>2014-08-07T17:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735317#M475131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i liked to do prior period SET ANALYSIS using a numerical counter of months ( or in this case quarters) that spans years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is an example of what you are asking&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the SET ANALYSIS is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$&amp;lt;QuarterCounter={$(vMaxQuarter),$(=vMaxQuarter-1)}&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where QuarterCounter is the running counter and vMaxQuarter is a variable =max( {1} QuarterCounter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;jonny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:01:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735317#M475131</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-08-07T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735318#M475132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;But the max of the Quarter will always be 4. so how can this be done?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:09:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735318#M475132</guid>
      <dc:creator />
      <dc:date>2014-08-07T18:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735319#M475133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the example there is Quarter (1 , 2, 3, 4) and in the load i added a brand new QuarterCounter field that assigns (1,2,3,4,5,6 etc... ) in progression to each quarter from earliest to latest time period. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that allows me to reference a quarter numerically &lt;EM&gt;&lt;SPAN style="text-decoration: underline;"&gt;across&lt;/SPAN&gt; &lt;/EM&gt;years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as you can see in the load script you need a calendar table that is sorted from earliest to latest with all the years and quarters in order to do this.&amp;nbsp; It means adding a calendar table to the data model but i think that is a good thing and it certainly makes YTD expressions easier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:16:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735319#M475133</guid>
      <dc:creator>JonnyPoole</dc:creator>
      <dc:date>2014-08-07T18:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735320#M475134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alternatively you could specify it in format YYYYQ.&lt;/P&gt;&lt;P&gt;As each quarter equals 3 months you can calculate quarter numbers with expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Year(addmonths(Today(),-3*1)) &amp;amp; ceil(num(Month(addmonths(Today(),-3*1)))/3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;replacing *1 with the number of quarters you want to go back or forth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 18:24:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735320#M475134</guid>
      <dc:creator />
      <dc:date>2014-08-07T18:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735321#M475135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Build a calendar table if you didn't already do that.&amp;nbsp; The Date field in your data will tie to the dates in your calendar.&amp;nbsp; You can add additional fields to your calendar for whatever you need to filter on or do date math with.&amp;nbsp; For example:&lt;/P&gt;&lt;P&gt;Date, CalYear, FiscalYear, FiscalQtr, FiscalYYYYQ, FiscalEOYDate, FiscalMonth, etc. &lt;/P&gt;&lt;P&gt;Most of the time business data contains future dates.&amp;nbsp;&amp;nbsp;&amp;nbsp; To handle this set up some macros/variables to&amp;nbsp; get the max non-future date in your filtered data.&amp;nbsp; That is better than using today() or max(date)since users may select a year range outside the current year.&amp;nbsp;&amp;nbsp;&amp;nbsp; You can use that in your set analysis or conditions... for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_MaxFiscalYear = if (Year(Today()) &amp;lt; max(FiscalYear),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(Today()),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(FiscalYear)&lt;/P&gt;&lt;P&gt;)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;FiscalYear={$(=v_MaxFiscalYear - 1)}&amp;gt;}&amp;nbsp; SomeField)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 19:42:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735321#M475135</guid>
      <dc:creator />
      <dc:date>2014-08-07T19:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting Latest 2 Quarters</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735322#M475136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use the P() function to select only the possible quarters within the respective year.&amp;nbsp; Something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;max({$&amp;lt;Quarter = P({$&amp;lt;YEAR=max(YEAR)&amp;gt;}) Quarter&amp;gt;})&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 19:54:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-Latest-2-Quarters/m-p/735322#M475136</guid>
      <dc:creator />
      <dc:date>2014-08-07T19:54:27Z</dc:date>
    </item>
  </channel>
</rss>

