<?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 DOES ANYONE KNOW HOW TO CALCULATE YTD AND MAT? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/DOES-ANYONE-KNOW-HOW-TO-CALCULATE-YTD-AND-MAT/m-p/228605#M504313</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Salvatore,&lt;/P&gt;&lt;P&gt;To calculate YTD it's the best to mkae Master Calendar in your script, and thenafter use flags. Here you can see mine example, that's working in personal eition 9:&lt;/P&gt;&lt;P&gt;LET vDateMin = Num(MakeDate(2008,1,1));&lt;BR /&gt;LET vDateMax = Floor(YearEnd(AddMonths(Today(), 1)));&lt;BR /&gt;LET vDateToday = Num(Today());&lt;BR /&gt;&lt;BR /&gt;TempCalendar:&lt;BR /&gt;LOAD&lt;BR /&gt; $(vDateMin) + RowNo() - 1 AS DateNumber,&lt;BR /&gt; Date($(vDateMin) + RowNo()-1) AS TempDate&lt;BR /&gt;AUTOGENERATE 1&lt;BR /&gt;WHILE $(vDateMin)+IterNo()-1&amp;lt;= $(vDateMax);&lt;BR /&gt;&lt;BR /&gt;MasterCalendar:&lt;BR /&gt;LOAD&lt;BR /&gt; TempDate AS CalendarDate,&lt;BR /&gt; Day(TempDate) AS CalendarDay,&lt;BR /&gt; Week(TempDate) AS CalendarWeek,&lt;BR /&gt; Weekday(TempDate) AS WeekDay,&lt;BR /&gt; Month(TempDate) AS CalendarMonth,&lt;BR /&gt; Year(TempDate) AS CalendarYear,&lt;BR /&gt; 'Q' &amp;amp; Ceil(Month(TempDate)/3) AS CalendarQuarter,&lt;BR /&gt; Month(TempDate) &amp;amp; '-' &amp;amp; Year(TempDate) AS CalendarMonthAndYear,&lt;BR /&gt; Week (TempDate) &amp;amp; '-'&amp;amp; Year (TempDate) as CalendarWeekAndYear,&lt;BR /&gt; Year2Date(TempDate, 0, 1, $(vToday))*-1 AS CurYTDFlag,&lt;BR /&gt; Year2Date(TempDate,-1, 1, $(vToday))*-1 AS LastYTDFlag&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RESIDENT TempCalendar&lt;BR /&gt;ORDER BY TempDate ASC;&lt;BR /&gt;&lt;BR /&gt;DROP TABLE TempCalendar;&lt;/P&gt;&lt;P&gt;After you will add this tab to your script it's very easy, you use simple expressions, ex:&lt;/P&gt;&lt;P&gt;Sum(CurYTDFlag*Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With movinga annual totat thing is more complicated. I am searching for sollution for one month already, but till now no full success. There are two ways to do smth like MAT:&lt;/P&gt;&lt;P&gt;a) try to find on forum posts about Rolling Months&lt;/P&gt;&lt;P&gt;b) use the bar chart, with simple expression : Sum(Sales) and in the expressions tab, click the option 'Accumulate' and choose 12 previous months. Unfortunate;y in this case it will show data for all months you have, instead of last 12 only. Acha and don't forget to use proper dimension, in my case it's =makedate(CalendarYear,CalendarMonth) - so it shows all months in given yers.&lt;/P&gt;&lt;P&gt;Good luck, if you will know something more about MAT, let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Feb 2010 11:49:44 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-02-02T11:49:44Z</dc:date>
    <item>
      <title>DOES ANYONE KNOW HOW TO CALCULATE YTD AND MAT?</title>
      <link>https://community.qlik.com/t5/QlikView/DOES-ANYONE-KNOW-HOW-TO-CALCULATE-YTD-AND-MAT/m-p/228604#M504312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all, I just kept in touch with QW. I'm struggling in calculating YTD and MAT. I have very simple data source, classified as follow: Class, Product, and Sales splitted over the last three years. I already built up a PIVOT table, and I need to calculate YTD and MAT. I tried with different expressions but they don't work at all. Please does anyone know how to calculate Them? I attached the file where I'm working on...&lt;/P&gt;&lt;P&gt;Thanks in advance for your help&lt;/P&gt;&lt;P&gt;PS. I have QW personal edition, please if you modify the attached file, make it downloadable for me...thank you again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2010 10:29:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/DOES-ANYONE-KNOW-HOW-TO-CALCULATE-YTD-AND-MAT/m-p/228604#M504312</guid>
      <dc:creator />
      <dc:date>2010-02-02T10:29:02Z</dc:date>
    </item>
    <item>
      <title>DOES ANYONE KNOW HOW TO CALCULATE YTD AND MAT?</title>
      <link>https://community.qlik.com/t5/QlikView/DOES-ANYONE-KNOW-HOW-TO-CALCULATE-YTD-AND-MAT/m-p/228605#M504313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Salvatore,&lt;/P&gt;&lt;P&gt;To calculate YTD it's the best to mkae Master Calendar in your script, and thenafter use flags. Here you can see mine example, that's working in personal eition 9:&lt;/P&gt;&lt;P&gt;LET vDateMin = Num(MakeDate(2008,1,1));&lt;BR /&gt;LET vDateMax = Floor(YearEnd(AddMonths(Today(), 1)));&lt;BR /&gt;LET vDateToday = Num(Today());&lt;BR /&gt;&lt;BR /&gt;TempCalendar:&lt;BR /&gt;LOAD&lt;BR /&gt; $(vDateMin) + RowNo() - 1 AS DateNumber,&lt;BR /&gt; Date($(vDateMin) + RowNo()-1) AS TempDate&lt;BR /&gt;AUTOGENERATE 1&lt;BR /&gt;WHILE $(vDateMin)+IterNo()-1&amp;lt;= $(vDateMax);&lt;BR /&gt;&lt;BR /&gt;MasterCalendar:&lt;BR /&gt;LOAD&lt;BR /&gt; TempDate AS CalendarDate,&lt;BR /&gt; Day(TempDate) AS CalendarDay,&lt;BR /&gt; Week(TempDate) AS CalendarWeek,&lt;BR /&gt; Weekday(TempDate) AS WeekDay,&lt;BR /&gt; Month(TempDate) AS CalendarMonth,&lt;BR /&gt; Year(TempDate) AS CalendarYear,&lt;BR /&gt; 'Q' &amp;amp; Ceil(Month(TempDate)/3) AS CalendarQuarter,&lt;BR /&gt; Month(TempDate) &amp;amp; '-' &amp;amp; Year(TempDate) AS CalendarMonthAndYear,&lt;BR /&gt; Week (TempDate) &amp;amp; '-'&amp;amp; Year (TempDate) as CalendarWeekAndYear,&lt;BR /&gt; Year2Date(TempDate, 0, 1, $(vToday))*-1 AS CurYTDFlag,&lt;BR /&gt; Year2Date(TempDate,-1, 1, $(vToday))*-1 AS LastYTDFlag&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RESIDENT TempCalendar&lt;BR /&gt;ORDER BY TempDate ASC;&lt;BR /&gt;&lt;BR /&gt;DROP TABLE TempCalendar;&lt;/P&gt;&lt;P&gt;After you will add this tab to your script it's very easy, you use simple expressions, ex:&lt;/P&gt;&lt;P&gt;Sum(CurYTDFlag*Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With movinga annual totat thing is more complicated. I am searching for sollution for one month already, but till now no full success. There are two ways to do smth like MAT:&lt;/P&gt;&lt;P&gt;a) try to find on forum posts about Rolling Months&lt;/P&gt;&lt;P&gt;b) use the bar chart, with simple expression : Sum(Sales) and in the expressions tab, click the option 'Accumulate' and choose 12 previous months. Unfortunate;y in this case it will show data for all months you have, instead of last 12 only. Acha and don't forget to use proper dimension, in my case it's =makedate(CalendarYear,CalendarMonth) - so it shows all months in given yers.&lt;/P&gt;&lt;P&gt;Good luck, if you will know something more about MAT, let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2010 11:49:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/DOES-ANYONE-KNOW-HOW-TO-CALCULATE-YTD-AND-MAT/m-p/228605#M504313</guid>
      <dc:creator />
      <dc:date>2010-02-02T11:49:44Z</dc:date>
    </item>
  </channel>
</rss>

