<?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: Set analysis - less than date minus 1 year in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758489#M269932</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;Were you meaning to have one expression showing 12 months of sales based on a selection or just all loaded data?&lt;/P&gt;&lt;P&gt;Your current approach would show all sales occurring before the highest date value of loaded data, not necessarily the current year.&lt;/P&gt;&lt;P&gt;Following from this, if you wanted to show the previous year you can either use the InYearToDate function or a range (my preference) using concatenation in set analysis.&lt;/P&gt;&lt;P&gt;In my experience using a separate calendar as a data island has been very effective in providing MTD/YTD along with same period last year and so forth. What were you using as a calendar table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any case you could try a set expression similar to below:&lt;/P&gt;&lt;P&gt;Date = {"$(= '&amp;gt;=' &amp;amp; MonthStart(max(Date),-24) &amp;amp; '&amp;lt;=' &amp;amp; MonthEnd(max(Date),-12))"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may need to swap between &amp;gt;,&amp;gt;=, and -24 or -25 depending on how your dates are set up.&lt;/P&gt;&lt;P&gt;If you want to try scripting in a master calendar along with data island calendar I believe there are some other threads/blogs on here which cover the topic quite well.&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Dec 2014 02:04:57 GMT</pubDate>
    <dc:creator>milkyryan</dc:creator>
    <dc:date>2014-12-18T02:04:57Z</dc:date>
    <item>
      <title>Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758488#M269931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a statement in my set analysis as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date={'&amp;lt;=$(=max(Date))'} and this works fine. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now need to create another column for the previous yr and hence need a statement which gives me the max(Date) minus 1 year. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date={'&amp;lt;=$(=AddYears(max(Date),-1))'}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but can't seem to get this working? Can anyone point me in the right direction please? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks &lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 01:31:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758488#M269931</guid>
      <dc:creator>canoebi99</dc:creator>
      <dc:date>2014-12-18T01:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758489#M269932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;Were you meaning to have one expression showing 12 months of sales based on a selection or just all loaded data?&lt;/P&gt;&lt;P&gt;Your current approach would show all sales occurring before the highest date value of loaded data, not necessarily the current year.&lt;/P&gt;&lt;P&gt;Following from this, if you wanted to show the previous year you can either use the InYearToDate function or a range (my preference) using concatenation in set analysis.&lt;/P&gt;&lt;P&gt;In my experience using a separate calendar as a data island has been very effective in providing MTD/YTD along with same period last year and so forth. What were you using as a calendar table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any case you could try a set expression similar to below:&lt;/P&gt;&lt;P&gt;Date = {"$(= '&amp;gt;=' &amp;amp; MonthStart(max(Date),-24) &amp;amp; '&amp;lt;=' &amp;amp; MonthEnd(max(Date),-12))"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may need to swap between &amp;gt;,&amp;gt;=, and -24 or -25 depending on how your dates are set up.&lt;/P&gt;&lt;P&gt;If you want to try scripting in a master calendar along with data island calendar I believe there are some other threads/blogs on here which cover the topic quite well.&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 02:04:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758489#M269932</guid>
      <dc:creator>milkyryan</dc:creator>
      <dc:date>2014-12-18T02:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758490#M269933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for the response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am dealing with the years in the set analysis and I am setting these separately so that the columns are giving me the right years data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement I posted above is to then let me get the data for those previous years only up to a certain date within that year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially I am trying to show comparisons for the same period in each column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hence, when the user selects a year, month and date range, then I am collecting the max date from this selection which gives me the date that I need to get all transactions up to for the YTD figure. Hence, my statement above works well for the current YTD based on the selections they have made.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need to achieve is to get the prev year and prior years columns to show their data for up to the same date but minus a year. (Hence, why I want to take a year of the max selected date).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 02:17:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758490#M269933</guid>
      <dc:creator>canoebi99</dc:creator>
      <dc:date>2014-12-18T02:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758491#M269934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;The problem you'll have (and depending on how your set expression works e.g. {$&amp;lt; vs {1&amp;lt;) is that when the user selects a year or month, the set won't return prior year data as it's filtered out via selections.&lt;/P&gt;&lt;P&gt;This was the main reason I used a data island (i.e. no joins to any other tables) calendar for the purposes of driving all date-driven expressions using set analysis where selecting one year still allows sums/accumulation over 1,2,3 or as many years prior to the selected year.&lt;/P&gt;&lt;P&gt;See below example table layout with calendar data island, selections would be made on this table then set analysis performed based on the calendar/dates in linked tables.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QV_SelectCalendar.jpg" class="image-1 jive-image" src="https://community.qlik.com/legacyfs/online/73756_QV_SelectCalendar.jpg" style="height: 244px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 02:29:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758491#M269934</guid>
      <dc:creator>milkyryan</dc:creator>
      <dc:date>2014-12-18T02:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758492#M269935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the set analysis to clear any of the fields they might make a selection on so as to return the whole data for the prior year (up to the Date I need) so my whole statement would be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;FiscalYear&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={'$(vPrevFiscYear)'}, , FiscMonth =, Day= , Date={'&amp;lt;=#(=AddYears(max(Date),-1)'}&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt; &amp;gt;}((&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;AgentGross&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) / 23) *20) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;I was thinking that by clearing the fiscmonth and day selections and setting the fiscal year to the prev year I could then use the Date set analysis statement to report data up to the maximum selected date minus 1 year (Hence, giving me a comparison column for the prev yr for the same period)? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Ben&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 02:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758492#M269935</guid>
      <dc:creator>canoebi99</dc:creator>
      <dc:date>2014-12-18T02:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758493#M269936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;You could try using sum({1&amp;lt; but I think you'll find the selections made in Date will still affect the set analysis.&lt;/P&gt;&lt;P&gt;This was the main reason I opt for using data island calendar as the set expressions are easier without having to remove selections on related fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be pretty quick and easy to test the data island approach, just do a resident load of your existing calendar and rename all fields with "Select" prefix, change selection boxes to use the data island calendar and try the new set expression.&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, 18 Dec 2014 03:13:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758493#M269936</guid>
      <dc:creator>milkyryan</dc:creator>
      <dc:date>2014-12-18T03:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758494#M269937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post sample app&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 05:32:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758494#M269937</guid>
      <dc:creator>anbu1984</dc:creator>
      <dc:date>2014-12-18T05:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758495#M269938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you've stated, you want to ignore any date-specific filters which may contradict your set analysis, unless you're using the {1} set identifier. These are usually the Year, Month, Qtr, Week or Day filters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then something like this should work:&lt;/P&gt;&lt;P&gt;Prior Year = sum({&amp;lt;FiscYear=, FiscMonth=, Day=, Date = {"&amp;lt;=$(=addyears(max(Date), -1))"}&amp;gt;} (AgentGross/23)*20)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Dec 2014 05:46:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758495#M269938</guid>
      <dc:creator>shawn-qv</dc:creator>
      <dc:date>2014-12-18T05:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Set analysis - less than date minus 1 year</title>
      <link>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758496#M269939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brilliant Shawn, just what i was looking for thanks:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;=addyears(max(Date), -1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;works a treat &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2017 12:35:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-analysis-less-than-date-minus-1-year/m-p/758496#M269939</guid>
      <dc:creator>wonkymeister</dc:creator>
      <dc:date>2017-01-17T12:35:59Z</dc:date>
    </item>
  </channel>
</rss>

