<?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 at script level in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/YTD-calculation-at-script-level/m-p/1368146#M844097</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandip,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the problem is caused by using the MIN() and MAX() functions in the where clause - I doubt if this is a correct syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What we usually do is calculate MIN and MAX upfront, store them in two variables, and then use the variables in the next LOAD statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, we don't typically pre-calculate the YTD amounts - instead, we calculate a calendar Flag for Current YTD dates and for Prior YTD dates, and then use the flags in chart expressions - you can either multiply the amounts by the flags, or use Set Analysis to filter by flags.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can learn these techniques, along with many other advanced Qlik techniques, from my book &lt;A href="http://https//www.amazon.com/gp/product/1118949552/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1118949552&amp;amp;linkCode=as2&amp;amp;tag=natursyner0f-20&amp;amp;linkId=098202df27917ab9836332cf063c51f5"&gt;QlikView Your Business: An Expert Guide to Business Discovery with QlikView and Qlik Sense&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;Oleg Troyansky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Apr 2017 19:01:30 GMT</pubDate>
    <dc:creator>Oleg_Troyansky</dc:creator>
    <dc:date>2017-04-09T19:01:30Z</dc:date>
    <item>
      <title>YTD calculation at script level</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-at-script-level/m-p/1368145#M844096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;I am using the below code to calculate YTD based on Order Date:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;&lt;STRONG&gt;[Temp Data]:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;load sum(Sales) as [YTD Sales],&amp;nbsp; [Order Date] resident extract &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;where [Order Date] &amp;gt;= Date(YearStart(Max([Order Date]), 0), 'D/M/YYYY')&amp;nbsp; and [Order Date] &amp;lt;= Date(AddYears(Max([Order Date]), 0), 'D/M/YYYY')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;group by&amp;nbsp; [Order Date] ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;and it gives me 'Unknown Error'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;Please let me know what is wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; font-size: 12pt;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: calibri, verdana, arial, sans-serif;"&gt;Sandip&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-at-script-level/m-p/1368145#M844096</guid>
      <dc:creator>ananyaghosh</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: YTD calculation at script level</title>
      <link>https://community.qlik.com/t5/QlikView/YTD-calculation-at-script-level/m-p/1368146#M844097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sandip,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the problem is caused by using the MIN() and MAX() functions in the where clause - I doubt if this is a correct syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What we usually do is calculate MIN and MAX upfront, store them in two variables, and then use the variables in the next LOAD statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, we don't typically pre-calculate the YTD amounts - instead, we calculate a calendar Flag for Current YTD dates and for Prior YTD dates, and then use the flags in chart expressions - you can either multiply the amounts by the flags, or use Set Analysis to filter by flags.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can learn these techniques, along with many other advanced Qlik techniques, from my book &lt;A href="http://https//www.amazon.com/gp/product/1118949552/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1118949552&amp;amp;linkCode=as2&amp;amp;tag=natursyner0f-20&amp;amp;linkId=098202df27917ab9836332cf063c51f5"&gt;QlikView Your Business: An Expert Guide to Business Discovery with QlikView and Qlik Sense&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;&lt;P&gt;Oleg Troyansky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Apr 2017 19:01:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/YTD-calculation-at-script-level/m-p/1368146#M844097</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2017-04-09T19:01:30Z</dc:date>
    </item>
  </channel>
</rss>

