<?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: MTD and YTD in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459770#M1165766</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Renjith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The easiest way I think is to create a calender with a Year and a YearMonth field in your script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try This: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Load ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Year(DATE) AS Year,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;date(monthstart(DATE), 'YYYY-MM') AS YearMonth,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;From ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Sum ({$&amp;lt;Year={$(=Max(Year))},&amp;nbsp;&amp;nbsp; DATE={'&amp;lt;=$(=Today())'} &amp;gt;} SALES)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives you the SUM(SALES) of the max(Year) form your data (up to today) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Sum ({$&amp;lt;YearMonth={$(=Max(YearMonth))},&amp;nbsp;&amp;nbsp; DATE={'&amp;lt;=$(=Today())'} &amp;gt;} SALES)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives you the SUM(SALES) of the max(YearMonth) form your data&amp;nbsp; (up to today)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2012 15:18:14 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-10-02T15:18:14Z</dc:date>
    <item>
      <title>MTD and YTD</title>
      <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459769#M1165765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anybody could please help me to find out the formulas for MTD and YTD, without selecting Year and Month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have done it with selecting Year and Month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 14:28:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459769#M1165765</guid>
      <dc:creator />
      <dc:date>2012-10-02T14:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: MTD and YTD</title>
      <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459770#M1165766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Renjith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The easiest way I think is to create a calender with a Year and a YearMonth field in your script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try This: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Load ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Year(DATE) AS Year,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;date(monthstart(DATE), 'YYYY-MM') AS YearMonth,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;From ...&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Sum ({$&amp;lt;Year={$(=Max(Year))},&amp;nbsp;&amp;nbsp; DATE={'&amp;lt;=$(=Today())'} &amp;gt;} SALES)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives you the SUM(SALES) of the max(Year) form your data (up to today) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;Sum ({$&amp;lt;YearMonth={$(=Max(YearMonth))},&amp;nbsp;&amp;nbsp; DATE={'&amp;lt;=$(=Today())'} &amp;gt;} SALES)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives you the SUM(SALES) of the max(YearMonth) form your data&amp;nbsp; (up to today)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 15:18:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459770#M1165766</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-02T15:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: MTD and YTD</title>
      <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459771#M1165767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Renjith,&lt;/P&gt;&lt;P&gt;This can be done in many ways...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case you want static result&lt;/STRONG&gt;----&lt;/P&gt;&lt;P&gt;1)Use&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;inyeartodate(D, $(vToday), 0) * -1 AS CYTD&amp;nbsp; in back end(&lt;/STRONG&gt;&lt;STRONG&gt;vToday=&lt;/STRONG&gt;LET vToday = vMaxDate;&lt;STRONG&gt;).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ansd in expression in FrontEnd use-----&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;sum(if(CYTD, LineSalesAmount)).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;For LYTD--&lt;/EM&gt;&lt;BR /&gt;sum(if(FPYTD, LineSalesAmount))&amp;nbsp; where FPYTD=inyeartodate(D, $(vToday), -1) * -1 AS FPYTD in Script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For MTD---sum(if(CMTD, LineSalesAmount))&lt;/P&gt;&lt;P&gt;Where &lt;STRONG&gt;CMTD=&lt;/STRONG&gt;inmonthtodate(D, $(vToday), 0) * -1 AS CMTD in script&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Previous month this year&lt;/STRONG&gt; sum(if(PM, LineSalesAmount))......&lt;/P&gt;&lt;P&gt;where&amp;nbsp; &lt;STRONG&gt;PM =&lt;/STRONG&gt;inmonth(D, $(vToday), -1) * -1 AS PM&amp;nbsp; in script&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;For Dyanamic result you have to go for the Selection....or you can go as Dennis have recommended but you have to bypass the Year and Month Field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=num(sum({&amp;lt;[Fiscal Month]=, [Fiscal Quarter]=,[Fiscal Year]={$(=max([Fiscal Year]))},[ Date]={"&amp;lt;=$(vCurrDate)"}&amp;gt;}[Sales])) .&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it help.I have also bypass Quarter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kamal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 15:42:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459771#M1165767</guid>
      <dc:creator>kamalqlik</dc:creator>
      <dc:date>2012-10-02T15:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: MTD and YTD</title>
      <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459772#M1165768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dennis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the first was working fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but the second (&lt;STRONG style="background-color: #ffffff; font-size: 12px; color: #636363; font-family: Arial;"&gt;&lt;EM&gt;Sum ({$&amp;lt;YearMonth={$(=Max(YearMonth))},&amp;nbsp;&amp;nbsp; DATE={'&amp;lt;=$(=Today())'} &amp;gt;} SALES)&lt;/EM&gt;&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;returns a null value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please have a look on that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 16:54:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459772#M1165768</guid>
      <dc:creator />
      <dc:date>2012-10-02T16:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: MTD and YTD</title>
      <link>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459773#M1165769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;It is working wrong because max(yeaMonth) is returning the null value in your case.&lt;/P&gt;&lt;P&gt;This is because you must be using....&lt;/P&gt;&lt;P&gt;(Month(Date)&amp;amp;'-'&amp;amp; right(Year(Date),2)) as YearMonth for calculating YearMonth or some other method for calculating YearMonth.&lt;/P&gt;&lt;P&gt;This is text field and when you are using max(YearMonth) it will return null value.&lt;/P&gt;&lt;P&gt;So you have to change it to a number format.&lt;/P&gt;&lt;P&gt;So use Like this to make yearmonth&lt;/P&gt;&lt;P&gt;The field that you have made Yearmonth,&lt;/P&gt;&lt;P&gt;Make a resident table with all the field&lt;/P&gt;&lt;P&gt;and use&lt;/P&gt;&lt;P&gt;Date(Date(Date#(YearMonth,'MMM-YY'),'DD-MM-YYYY'),'MMM-YY') as YearMonth1,&lt;/P&gt;&lt;P&gt;resident your table.&lt;/P&gt;&lt;P&gt;To make the YearMonth Number.&lt;/P&gt;&lt;P&gt;and use this YearMonth1 in your expression.&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regard&lt;/P&gt;&lt;P&gt;KAmal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2012 07:49:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/MTD-and-YTD/m-p/459773#M1165769</guid>
      <dc:creator>kamalqlik</dc:creator>
      <dc:date>2012-10-03T07:49:09Z</dc:date>
    </item>
  </channel>
</rss>

