<?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 Am i using correct logic for Year to date calender year in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252247#M95617</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;make year in script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year(OrderDate) as Year&lt;/P&gt;&lt;P&gt;and now try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(if( Year&amp;gt;=Year(Today()) and OrderDate&amp;lt;=Today() ,Netamountpaid))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Aug 2011 11:55:11 GMT</pubDate>
    <dc:creator>SunilChauhan</dc:creator>
    <dc:date>2011-08-05T11:55:11Z</dc:date>
    <item>
      <title>Am i using correct logic for Year to date calender year</title>
      <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252243#M95613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i want to calculate sales for Year to date. that is a calender year not fiscal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that means from 1st january current year to today&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using following logic. is it correct? if it is not then why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(OrderDate&amp;lt;=Today() and OrderDate&amp;gt;=YearStart(Today()),sum(Netamountpaid))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Lavi&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 11:10:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252243#M95613</guid>
      <dc:creator>harleen_singh</dc:creator>
      <dc:date>2011-08-05T11:10:15Z</dc:date>
    </item>
    <item>
      <title>Am i using correct logic for Year to date calender year</title>
      <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252244#M95614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hope this help &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(if( OrderDate&amp;gt;=YearStart(Today()) and OrderDate&amp;lt;=Today() ,Netamountpaid))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 11:18:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252244#M95614</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2011-08-05T11:18:18Z</dc:date>
    </item>
    <item>
      <title>Am i using correct logic for Year to date calender year</title>
      <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252245#M95615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks but its not working returning 0 only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Lavi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 11:27:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252245#M95615</guid>
      <dc:creator>harleen_singh</dc:creator>
      <dc:date>2011-08-05T11:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Am i using correct logic for Year to date calender year</title>
      <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252246#M95616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lavi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be rather&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Sum(If(OrderDate &amp;lt;= Today() AND OrderDate &amp;gt;= YearStart(Today()), Netamountpaid))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the If() fits within the aggregation function Sum(). However, this will perform really poor with a few hundreds of records, so you better create a flag field in the script to know wheter a date fits or doesn't fit in the year to date calculation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Table:&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InYearToDate(DateField, Date('28/02/2011'), 0, 3) AS FlagYTD&lt;/P&gt;&lt;P&gt;FROM ...&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression above will return true ("-1") if the value in field "DateField" is between "01/03/2011" (that's because the 3 as the fourth parameter, that indicates the fiscal year starts on August) and "28/02/2012".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once this is built, the expression to sum between both dates would look like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Sum({&amp;lt; FlagYTD = {'-1'} &amp;gt;} Netamountpaid)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now using variables you can compare to year to date periods of previous years and so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that in QlikView both field names and values are case sensitive. Not as well that in your expression OrderDate must have the same exact format than the returned by "Today()" or "YearStart(Today())". Another advantage of flag fields is that you don't have to care about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/people/mabaeyens" style="font-size: 12px; outline-style: none; padding-top: 1px; padding-bottom: 1px; padding-left: 17px; color: #007fc0; zoom: 1; background-position: no-repeat no-repeat;"&gt;Miguel Angel Baeyens&lt;/A&gt;&lt;/P&gt;&lt;P&gt;BI Consultant&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.grupocomex.com/" style="font-size: 12px; outline-style: none; color: #007fc0;"&gt;Comex Grupo Ibérica&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 11:40:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252246#M95616</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-08-05T11:40:26Z</dc:date>
    </item>
    <item>
      <title>Am i using correct logic for Year to date calender year</title>
      <link>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252247#M95617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;make year in script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year(OrderDate) as Year&lt;/P&gt;&lt;P&gt;and now try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(if( Year&amp;gt;=Year(Today()) and OrderDate&amp;lt;=Today() ,Netamountpaid))&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2011 11:55:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Am-i-using-correct-logic-for-Year-to-date-calender-year/m-p/252247#M95617</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2011-08-05T11:55:11Z</dc:date>
    </item>
  </channel>
</rss>

