<?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 YTD based on selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827240#M291265</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Qlikers,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I am in trouble with a Set Analysis expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Suppose to have a Qlik app which include some orders with date and amount (very typical situation).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Then, I have a set analysis expression to calculate YTD amount for this year (i.e. 2014) and for the previous year (2013).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I would like to calculate YTD amount and compare with YTD previous year if you select the current year, which is not complete (for example, 2014/2013), but to calculate the entire amount if you select a previous year (2013/2012)).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;YTD amount for 1st year: Sum({$&amp;lt;Year = {"$(=max(Year))"}&amp;gt;} Amount)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If there is no selection it takes 2014 and there is no problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If the user select an year (for example, 2013) there is no problem because it takes the all year.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;YTD amount for the 2nd year:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Sum({$&amp;lt;OrderDate = {“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;$(AddYears(=Max(OrderDate)),-1)”}, Year = {"$(=max(Year)-1)"}&amp;gt;} Amount)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;(Suppose that today is: 27/11/2014)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If there is no selection it takes all the order with order date &amp;lt;= 27/11/2013 and that's ok!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If the user select 2013 and the max order date is 29/12/2013, the expression calculate the YTD previous year date -&amp;gt; 29/12/2012.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;STRONG&gt;But, if there is an order of 31/12/2012 it will not be included!&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Where am I wrong?!?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Ps. I know there could be some syntax error in the expression, I wrote directly here to simplify the real situation. &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>Thu, 27 Nov 2014 15:49:19 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-11-27T15:49:19Z</dc:date>
    <item>
      <title>YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827240#M291265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Qlikers,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I am in trouble with a Set Analysis expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Suppose to have a Qlik app which include some orders with date and amount (very typical situation).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Then, I have a set analysis expression to calculate YTD amount for this year (i.e. 2014) and for the previous year (2013).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I would like to calculate YTD amount and compare with YTD previous year if you select the current year, which is not complete (for example, 2014/2013), but to calculate the entire amount if you select a previous year (2013/2012)).&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;YTD amount for 1st year: Sum({$&amp;lt;Year = {"$(=max(Year))"}&amp;gt;} Amount)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If there is no selection it takes 2014 and there is no problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If the user select an year (for example, 2013) there is no problem because it takes the all year.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;YTD amount for the 2nd year:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Sum({$&amp;lt;OrderDate = {“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;$(AddYears(=Max(OrderDate)),-1)”}, Year = {"$(=max(Year)-1)"}&amp;gt;} Amount)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;(Suppose that today is: 27/11/2014)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If there is no selection it takes all the order with order date &amp;lt;= 27/11/2013 and that's ok!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If the user select 2013 and the max order date is 29/12/2013, the expression calculate the YTD previous year date -&amp;gt; 29/12/2012.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;STRONG&gt;But, if there is an order of 31/12/2012 it will not be included!&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Where am I wrong?!?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Ps. I know there could be some syntax error in the expression, I wrote directly here to simplify the real situation. &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>Thu, 27 Nov 2014 15:49:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827240#M291265</guid>
      <dc:creator />
      <dc:date>2014-11-27T15:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827241#M291266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi tomasso &lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;$(AddYears(=Max(OrderDate)),-1)” will return the max order date minus one year, you can use YearEnd() if you want the full year:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;$(=YearEnd(AddYears(Max(OrderDate)),-1))”&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Nov 2014 16:29:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827241#M291266</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2014-11-27T16:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827242#M291267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer Ruben!&lt;/P&gt;&lt;P&gt;But it's not what I'm looking for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I consider this year (2014) I would like to compare data from 1/1/2014 to 27/11/2014 (in the 1st expression) with data from 1/1/2013 to 27/11/2013 (in the 2nd expression). While the expression you suggest will consider the entire year, from 1/1/2013 to 31/12/2013.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Nov 2014 16:46:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827242#M291267</guid>
      <dc:creator />
      <dc:date>2014-11-27T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827243#M291268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, so, if you want different max date depending if it's the current or previous years you can use:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;$(=If(Max(Year)=Year(Today()), &lt;SPAN style="font-size: 10pt;"&gt;AddYears(Today(),-1),&lt;/SPAN&gt; YearEnd(AddYears(Max(OrderDate),-1)))”&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that I changed max(Order date) in currrent year, ie, if today is 28/11/2014 and the max Order date is 26/11/2014, it will still get amount from 01/01/2013 to 28/11/2013.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If for current year you want to compare to yesterday (not counting today), you can use:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;“&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;$(=If(Max(Year)=Year(Today()), &lt;SPAN style="font-size: 10pt;"&gt;AddYears(Today()-1,-1),&lt;/SPAN&gt; YearEnd(AddYears(Max(OrderDate),-1)))”&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 08:01:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827243#M291268</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2014-11-28T08:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827244#M291269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ruben! It works!!!&lt;/P&gt;&lt;P&gt;Could be possible to do it also without using IF?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 14:45:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827244#M291269</guid>
      <dc:creator />
      <dc:date>2014-11-28T14:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: YTD based on selection</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827245#M291270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't get how doing it without "if", anyway, set analisys is calculated for the whole table, not row by row, so I don't think that "if" would be a performance issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 07:49:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-based-on-selection/m-p/827245#M291270</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2014-12-01T07:49:05Z</dc:date>
    </item>
  </channel>
</rss>

