<?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: YTD calculation that works with filtered date dimension in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55412#M458378</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RangeSum(Above(Sum({&amp;lt;Month&amp;gt;}Amount), 0, Only({1}Month))) * Avg(1)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Mar 2018 17:09:32 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-03-20T17:09:32Z</dc:date>
    <item>
      <title>YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55411#M458377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following sample data:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;YearMonth&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201801&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201802&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201803&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201804&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201805&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201806&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201807&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;8&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201808&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;9&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201809&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201810&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201811&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201812&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can calculate the YTD on a straight table like so:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/196847_Capture.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;However when ever I make a selection on the Month field, the YTD calculation breaks like so (month 6 and 10 are selected):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture2.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/196848_Capture2.JPG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;The required result is:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Month&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;YTD Total&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;21&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;55&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to write the expression to calculate a YTD total, even when the date dimension in the visualisation is filtered?&lt;/P&gt;&lt;P&gt;I'd like to avoid calculating YTD totals during the script load stage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2018 11:37:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55411#M458377</guid>
      <dc:creator>MynhardtBurger</dc:creator>
      <dc:date>2018-03-20T11:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55412#M458378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RangeSum(Above(Sum({&amp;lt;Month&amp;gt;}Amount), 0, Only({1}Month))) * Avg(1)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2018 17:09:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55412#M458378</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-20T17:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55413#M458379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Sunny. Your suggested expression does work.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Are the following bold elements of the formula necessary?&lt;/P&gt;&lt;P&gt;RangeSum(Above(Sum({&amp;lt;Month&amp;gt;}Amount), 0, &lt;STRONG&gt;Only({1}&lt;/STRONG&gt;Month&lt;STRONG&gt;)&lt;/STRONG&gt;))&lt;STRONG&gt; * Avg(1)&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;Avg(1) should always return 1, so what is the point of multiplying by 1?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;Only() will return the value or null (if there are multiple &lt;/SPAN&gt;occurrences&lt;SPAN style="font-size: 10pt;"&gt;). Won't this possibly introduce bugs if NULL is returned?&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;{1} doesn't appear to matter, whether I filter on the [Month] field or not.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The following formula appears to work the same: RangeSum(Above(Sum({&amp;lt;[Month]&amp;gt;}Amount), 0, [Month]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to write such a YTD expression which isn't dependent on the sort order?&lt;/P&gt;&lt;P&gt;The suggested formula breaks as soon as the [Month] field's sorted in descending order from 12 to 1 (or any other sort order which isn't strictly ascending). See the example below:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="d47c0cba34ee4709bcff402fefdf318e.jpg" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/197036_d47c0cba34ee4709bcff402fefdf318e.jpg" style="height: 277px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:54:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55413#M458379</guid>
      <dc:creator>MynhardtBurger</dc:creator>
      <dc:date>2018-03-21T15:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55414#M458380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1) Avg(1) will only return for Month which are selected, for anything not selected... Avg(1) = 0. This is what I am using to remove Months which are not selected, because I am ignoring selection in the Month field in the main expression&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Why will it return Null? Month is a dimension and for every month... you have a possible month (sounds stupid... but it is true, right?) &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) I think it should not matter, but I just add it to be safe... feel free to remove it... if it works without Only and {1} after selection also&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:11:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55414#M458380</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-21T16:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55415#M458381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you are using Qlik Sense, you can def. create a sort independent expression using Aggr() function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="color: #ff0000;"&gt;Aggr(&lt;/SPAN&gt;RangeSum(Above(Sum({&amp;lt;[Month]&amp;gt;}Amount), 0, [Month]))&lt;SPAN style="color: #ff0000;"&gt;, (Month, (NUMERIC)))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read more about this here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4673"&gt;The sortable Aggr function is finally here!&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:13:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55415#M458381</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-03-21T16:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55416#M458382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use All member filter, so that irrespective of your date selection you would results,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{Starting selection &amp;lt;Dimension1 = {*} &amp;gt;} ({*} for numeric, {"*"} for text)&lt;/P&gt;&lt;P&gt;Or:&lt;/P&gt;&lt;P&gt;{Starting selection &amp;lt;Dimension1 = &amp;gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 03:11:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55416#M458382</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-22T03:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation that works with filtered date dimension</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55417#M458383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my previous attempts I got quite close to the solution, but ended up coming up just short due. Thanks for highlighting some of the areas where I misunderstood how the formulas worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2018 14:31:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-that-works-with-filtered-date-dimension/m-p/55417#M458383</guid>
      <dc:creator>MynhardtBurger</dc:creator>
      <dc:date>2018-03-22T14:31:47Z</dc:date>
    </item>
  </channel>
</rss>

