<?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: QTD calculation in Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773043#M454693</link>
    <description>&lt;P&gt;Hi Edwin,&lt;/P&gt;&lt;P&gt;Thanks for sharing your thoughts and it's valuable. Actually I am not having date field in my fact table, using month field I have created master calendar below is the one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find exact QTD for all the months instead of today() what logic can be used to get this done?&lt;/P&gt;&lt;P&gt;Sub Calendar&lt;BR /&gt;Calendar:&lt;BR /&gt;LOAD Month Resident Fact;&lt;/P&gt;&lt;P&gt;Temp:&lt;BR /&gt;Load&lt;BR /&gt;&lt;BR /&gt;min(makedate(2016,1,1)) as minDate,&lt;BR /&gt;&lt;BR /&gt;max(makedate(2020,12,31)) as maxDate&lt;BR /&gt;&lt;BR /&gt;Resident Calendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DROP Table Calendar;&lt;/P&gt;&lt;P&gt;Let varMinDate = Num(Peek('minDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;DROP Table Temp;&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;$(varMinDate) + Iterno()-1 As Num,&lt;BR /&gt;&lt;BR /&gt;Date($(varMinDate) + IterNo() - 1) as TempDate&lt;/P&gt;&lt;P&gt;AutoGenerate 1 While $(varMinDate) + IterNo() -1 &amp;lt;= $(varMaxDate);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YTDCalendar:&lt;BR /&gt;Load Distinct&lt;/P&gt;&lt;P&gt;Month(TempDate) As Month,&lt;BR /&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;BR /&gt;&lt;BR /&gt;'ITM' as PeriodScope&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;Concatenate (YTDCalendar)&lt;BR /&gt;Load&lt;BR /&gt;Month(TempDate) As Month,&lt;/P&gt;&lt;P&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;BR /&gt;If(DayNumberOfQuarter(TempDate) &amp;lt;= DayNumberOfQuarter(Today()) and Ceil(Month(TempDate)/3) = Ceil(Month(Today())/3), 'QTD') as PeriodScope&lt;BR /&gt;&lt;BR /&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;Concatenate(YTDCalendar)&lt;BR /&gt;LOAD&lt;BR /&gt;IterNo() as Month,&lt;BR /&gt;MonthDesc,&lt;BR /&gt;QtrMonth,&lt;BR /&gt;Quarter,&lt;BR /&gt;'YTD' as PeriodScope&lt;BR /&gt;Resident YTDCalendar&lt;BR /&gt;While IterNo() &amp;lt;= Month&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Drop Table TempCalendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;END SUB&lt;/P&gt;</description>
    <pubDate>Sat, 09 Jan 2021 10:18:14 GMT</pubDate>
    <dc:creator>krishna20</dc:creator>
    <dc:date>2021-01-09T10:18:14Z</dc:date>
    <item>
      <title>QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772773#M454680</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;I need to calculate QTD in script and using the below logic , but not working as expected. It gives me only latest QTD ,&amp;nbsp;I need logic for whole year.&lt;/P&gt;&lt;P&gt;If(DayNumberOfQuarter(TempDate) &amp;lt;= DayNumberOfQuarter(Today()) and Ceil(Month(TempDate)/3) = Ceil(Month(Today())/3)) as QTD&lt;/P&gt;&lt;P&gt;Expected O/P:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mar&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Apr&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;May&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jun&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jul&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Aug&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Sep&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Oct&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Nov&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dec&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could anyone help me to get the correct logic.&lt;/P&gt;&lt;P&gt;Reagrds&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 17:38:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772773#M454680</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2024-11-16T17:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772778#M454681</link>
      <description>&lt;P&gt;Any inputs??&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 03:31:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772778#M454681</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2021-01-08T03:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772858#M454682</link>
      <description>&lt;P&gt;assuming you have a range of Dates the user selects and you have a calendar, you can build a bridge that associates each date in the calendar to the respective QTD record in your fact table.&amp;nbsp; so the association will be like the following (sample for 02/05/2021):&lt;BR /&gt;&lt;BR /&gt;02/05/2021 -&amp;gt; 02/05/2021&lt;BR /&gt;02/05/2021 -&amp;gt; 02/04/2021&lt;BR /&gt;...&lt;BR /&gt;02/05/2021 -&amp;gt; 01/01/2021&lt;BR /&gt;&lt;BR /&gt;there are many ways to do this, one way would be to create a temporary table which is a cartesian join between your factdate and calendar, then filter out the dates that fall outside of the QTD condition:&lt;BR /&gt;&lt;BR /&gt;noconcatenate Bridge: load FactDate, Date, 'QTD' as DaterType resident tmpTable where quarterstart(FactDate)=quarterstart(Date) and FactDate&amp;lt;=Date;&lt;/P&gt;&lt;P&gt;of course you need to link the dailies:&lt;/P&gt;&lt;P&gt;concatenate (Bridge) load FactDate, FactDate as Date, 'DAILY' as DateType residnet tmpTable;&lt;/P&gt;&lt;P&gt;to use this, if you want to select only the Facts on the selected Date, add in your expression set analysis&lt;BR /&gt;&lt;BR /&gt;{&amp;lt; ..., DateType={'DAILY'}, ...&amp;gt;}&lt;/P&gt;&lt;P&gt;to get all the QTD rows (when user selects a Date in the Calendar, the following will link it to all the FactDates that is QTD):&lt;BR /&gt;&lt;BR /&gt;{&amp;lt; ..., DateType={'QTD'}, ...&amp;gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope that helps&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 14:13:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772858#M454682</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-08T14:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772862#M454683</link>
      <description>&lt;P&gt;as add on, if you want it on month granularity, just select the MONTH in the calendar and still use DateType={'QTD'}&lt;BR /&gt;&lt;BR /&gt;you can then expand this solution to MTD, YTD, PastQTD, PastMTD, PastYTD&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 14:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1772862#M454683</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-08T14:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773043#M454693</link>
      <description>&lt;P&gt;Hi Edwin,&lt;/P&gt;&lt;P&gt;Thanks for sharing your thoughts and it's valuable. Actually I am not having date field in my fact table, using month field I have created master calendar below is the one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find exact QTD for all the months instead of today() what logic can be used to get this done?&lt;/P&gt;&lt;P&gt;Sub Calendar&lt;BR /&gt;Calendar:&lt;BR /&gt;LOAD Month Resident Fact;&lt;/P&gt;&lt;P&gt;Temp:&lt;BR /&gt;Load&lt;BR /&gt;&lt;BR /&gt;min(makedate(2016,1,1)) as minDate,&lt;BR /&gt;&lt;BR /&gt;max(makedate(2020,12,31)) as maxDate&lt;BR /&gt;&lt;BR /&gt;Resident Calendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DROP Table Calendar;&lt;/P&gt;&lt;P&gt;Let varMinDate = Num(Peek('minDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;DROP Table Temp;&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;$(varMinDate) + Iterno()-1 As Num,&lt;BR /&gt;&lt;BR /&gt;Date($(varMinDate) + IterNo() - 1) as TempDate&lt;/P&gt;&lt;P&gt;AutoGenerate 1 While $(varMinDate) + IterNo() -1 &amp;lt;= $(varMaxDate);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YTDCalendar:&lt;BR /&gt;Load Distinct&lt;/P&gt;&lt;P&gt;Month(TempDate) As Month,&lt;BR /&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;BR /&gt;&lt;BR /&gt;'ITM' as PeriodScope&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;Concatenate (YTDCalendar)&lt;BR /&gt;Load&lt;BR /&gt;Month(TempDate) As Month,&lt;/P&gt;&lt;P&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;BR /&gt;If(DayNumberOfQuarter(TempDate) &amp;lt;= DayNumberOfQuarter(Today()) and Ceil(Month(TempDate)/3) = Ceil(Month(Today())/3), 'QTD') as PeriodScope&lt;BR /&gt;&lt;BR /&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;Concatenate(YTDCalendar)&lt;BR /&gt;LOAD&lt;BR /&gt;IterNo() as Month,&lt;BR /&gt;MonthDesc,&lt;BR /&gt;QtrMonth,&lt;BR /&gt;Quarter,&lt;BR /&gt;'YTD' as PeriodScope&lt;BR /&gt;Resident YTDCalendar&lt;BR /&gt;While IterNo() &amp;lt;= Month&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Drop Table TempCalendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;END SUB&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2021 10:18:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773043#M454693</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2021-01-09T10:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773070#M454699</link>
      <description>&lt;P&gt;Let's talk one year. Since you don't have date field in your calendar or fact. you need to do some manual (That make sense what your script already did)&lt;/P&gt;&lt;P&gt;But, Not entirely sure i understand your requirement on your logic? Can you brief little more on this part how you need expected and why you are trying in different like If--else.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/44466"&gt;@krishna20&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Expected O/P:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Jan&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Feb&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mar&lt;/TD&gt;&lt;TD&gt;Q1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Apr&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;May&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jun&lt;/TD&gt;&lt;TD&gt;Q2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Jul&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Aug&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Sep&lt;/TD&gt;&lt;TD&gt;Q3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Oct&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Nov&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Dec&lt;/TD&gt;&lt;TD&gt;Q4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Jan 2021 15:16:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773070#M454699</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2021-01-09T15:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773103#M454701</link>
      <description>&lt;P&gt;you are just changing the granularity of your data from DATE to month&lt;/P&gt;&lt;P&gt;from your script it looks like your date range is hard coded.&amp;nbsp; normally it should be in your Fact table (Month perhaps is a date field?)&amp;nbsp; you cant possibly have a Month field with just the Month name as Jan 2020 will then roll up with Jan 2021.&amp;nbsp; so it must be 1st of the month?&lt;/P&gt;&lt;P&gt;assuming Month is a date field&lt;/P&gt;&lt;P&gt;noconcatenate minMax: load date(min(Month)) as MinMonth, date(max(Month)) as MaxMonth resident Fact&lt;BR /&gt;//this gives you all the months between min and max months from your Fact&lt;BR /&gt;noconcatenate tmpBridge: load date(addmonths(MinMonth,iterno()-1)) as Month resident minMax&lt;BR /&gt;while&amp;nbsp;&amp;nbsp;date(addmonths(MinMonth,iterno()-1)) &amp;lt;=MaxMonth;&lt;BR /&gt;//this is a cartesian join&lt;BR /&gt;inner join (tmpBridge) load Month as SelectMonth resident tmpBridge;&lt;BR /&gt;//this builds the relationship between your selected Month and QTD&lt;BR /&gt;noconcatenate Bridge: load Month, SelectMonth, 'Q'&amp;amp;ceil(month(SelectMonth)/3) as Quarter, 'QTD' as MonthType resident tmpBridge&lt;BR /&gt;where quarterstart(Month) = quarterstart(SelectMonth);&lt;BR /&gt;drop table tmpBridge;&lt;BR /&gt;&lt;BR /&gt;to get the QTD let user select SelectMonth field, then in your set analysis use DateType={'QTD'}&amp;nbsp; it will give you all the months for same quarter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 03:20:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773103#M454701</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-10T03:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773104#M454702</link>
      <description>&lt;P&gt;check this out&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 03:27:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773104#M454702</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-10T03:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773207#M454708</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/5533"&gt;@Anil_Babu_Samineni&lt;/a&gt;&amp;nbsp;- I have given the requirement details and explanation what is using for what. Please let me know if you need any details further.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/58578"&gt;@edwin&lt;/a&gt;&amp;nbsp;- Thanks a lot for your suggestions, I am looking for "QTD" not for Quarter calculation. We already have Quarter in the calendar.&lt;/P&gt;&lt;P&gt;// Target of the requirement is need to create to flags for MTD, YTD, QTD . This flags should effect to all the data in the application without using any set analysis. For now it is working MTD and YTD. Now we are looking for QTD to calculate like the Same.&lt;BR /&gt;Sub Calendar&lt;BR /&gt;Calendar:&lt;BR /&gt;// Since not having date field in the data, calendar is creating using the month field from fact.&lt;BR /&gt;LOAD Month Resident Fact;&lt;/P&gt;&lt;P&gt;Temp:&lt;BR /&gt;Load&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//Hard coding the dates FROM and TO&lt;BR /&gt;min(makedate(2016,1,1)) as minDate,&lt;/P&gt;&lt;P&gt;max(makedate(2020,12,31)) as maxDate&lt;/P&gt;&lt;P&gt;Resident Calendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DROP Table Calendar;&lt;/P&gt;&lt;P&gt;Let varMinDate = Num(Peek('minDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));&lt;/P&gt;&lt;P&gt;DROP Table Temp;&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;$(varMinDate) + Iterno()-1 As Num,&lt;/P&gt;&lt;P&gt;Date($(varMinDate) + IterNo() - 1) as TempDate&lt;/P&gt;&lt;P&gt;AutoGenerate 1 While $(varMinDate) + IterNo() -1 &amp;lt;= $(varMaxDate);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;YTDCalendar:&lt;BR /&gt;Load Distinct&lt;BR /&gt;// Creating MTD flag using Tempdate&lt;BR /&gt;Month(TempDate) As Month,&lt;BR /&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;/P&gt;&lt;P&gt;'MTD' as PeriodScope&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;Concatenate (YTDCalendar)&lt;BR /&gt;Load&lt;BR /&gt;Month(TempDate) As Month,&lt;/P&gt;&lt;P&gt;// Creating QTD flag using Tempdate&lt;BR /&gt;Date(Date#(Month(TempDate),'MMM'),'MMM') as MonthDesc,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) as Quarter,&lt;BR /&gt;'Q'&amp;amp;Ceil(Num(Month(AddMonths(TempDate,0)))/3) &amp;amp;'_'&amp;amp; Date(Date#(Month(TempDate),'MMM'),'MMM') as QtrMonth,&lt;/P&gt;&lt;P&gt;// While creating QTD flag, we have been used today() function so it is effecting only to current Quarter. Can we achieve using any other logic, QTD should effect to all the 12 months?&lt;BR /&gt;If(DayNumberOfQuarter(TempDate) &amp;lt;= DayNumberOfQuarter(Today()) and Ceil(Month(TempDate)/3) = Ceil(Month(Today())/3), 'QTD') as PeriodScope&lt;/P&gt;&lt;P&gt;Resident TempCalendar;&lt;/P&gt;&lt;P&gt;//Creating YTD flag using IterNo()&lt;BR /&gt;Concatenate(YTDCalendar)&lt;BR /&gt;LOAD&lt;BR /&gt;IterNo() as Month,&lt;BR /&gt;MonthDesc,&lt;BR /&gt;QtrMonth,&lt;BR /&gt;Quarter,&lt;BR /&gt;'YTD' as PeriodScope&lt;BR /&gt;Resident YTDCalendar&lt;BR /&gt;While IterNo() &amp;lt;= Month&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Drop Table TempCalendar;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;END SUB&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 05:25:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773207#M454708</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2021-01-11T05:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773369#M454716</link>
      <description>&lt;P&gt;this is not quarter calculation, if March is selected, Jan, Feb, and Mar are possible selections; if Feb is selected only Jan and Feb are possible selections.&amp;nbsp; since you r data is at month level, your requirement isnt really QTD but Quarter to Month.&amp;nbsp; QTD means it is from first to the quarter to the actual date and not month&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 13:52:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773369#M454716</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-11T13:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773589#M454729</link>
      <description>&lt;P&gt;Yes, you got my point. Since I am not having Date field in my data, whenever I selects March Jan,Feb, mar are possible selections like same for all 12 months.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 06:56:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773589#M454729</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2021-01-12T06:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773724#M454739</link>
      <description>&lt;P&gt;it is unusual that your Month field is a text field and you dont have a Date type field.&amp;nbsp; you may want to reconsider as there are a lot of functionality that can be applied to date types (sorting is one - you need to make your field a dual or create a second field so you can sort the months properly.)&amp;nbsp; also, once you need to address requirements for future date, your months will be screwed up.&lt;/P&gt;&lt;P&gt;having said that you can still implement a similar solution but it will be mostly hard coded:&lt;BR /&gt;&lt;BR /&gt;Months: load * inline [&lt;BR /&gt;SelectMonth,Month,MonthSeq,Quarter&lt;BR /&gt;Jan,Jan,1,Q1&lt;BR /&gt;Feb,Jan,1,Q1&lt;BR /&gt;Feb,Feb,2,Q1&lt;BR /&gt;Mar,Jan,1,Q1&lt;BR /&gt;Mar,Feb,2,Q1&lt;BR /&gt;Mar,Mar,3,Q1&lt;BR /&gt;Apr,Apr,4,Q2&lt;BR /&gt;May,Apr,4,Q2&lt;BR /&gt;May,May,5,Q2&lt;BR /&gt;Jun,Apr,4,Q2&lt;BR /&gt;Jun,May,5,Q2&lt;BR /&gt;Jun,Jun,6,Q2&lt;BR /&gt;Jul,Jul,7,Q3&lt;BR /&gt;Aug,Jul,7,Q3&lt;BR /&gt;Aug,Aug,8,Q3&lt;BR /&gt;Sep,Jul,7,Q3&lt;BR /&gt;Sep,Aug,8,Q3&lt;BR /&gt;Sep,Sep,9,Q3&lt;BR /&gt;Oct,Oct,10,Q4&lt;BR /&gt;Nov,Oct,10,Q4&lt;BR /&gt;Nov,Nov,11,Q4&lt;BR /&gt;Dec,Oct,10,Q4&lt;BR /&gt;Dec,Nov,11,Q4&lt;BR /&gt;Dec,Dec,12,Q4&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;you let the user select the field SelectMonth and it will automatically link to all months that is Quarter to the Month:&lt;BR /&gt;&lt;BR /&gt;select Mar -&amp;gt; Jan, Feb, Mar&lt;BR /&gt;select May -&amp;gt; Apr, May&lt;BR /&gt;select start of quarter Oct -&amp;gt; Oct only&lt;/P&gt;&lt;P&gt;you can get away with hard coding as there will always only be 12 months and the relationship to Quarter to the month will never change (again assuming Month is not a DATE type but text)&lt;/P&gt;&lt;P&gt;MonthSeq will allow you to sort the months Jan -&amp;gt; Dec.&amp;nbsp; it will get a bit complicated when you are in March and the user requests sorting to start March -&amp;gt; Feb&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 14:21:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773724#M454739</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-12T14:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773727#M454741</link>
      <description>&lt;P&gt;this is the programmatic way of doing it in case you are interested (same logic when you are using dates):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tmpMonths: 
load text(month(addmonths(date('1/1/2021'), iterno()-1))) as Month, iterno() as MonthSeq, 'Q' &amp;amp; (floor((iterno()+2)/3)) as Quarter
while iterno()&amp;lt;=12; load 1 AutoGenerate(1);

inner join (tmpMonths)
load Month as SelectMonth, MonthSeq as SelectSeq, Quarter as SelectQuarter
Resident tmpMonths;
NoConcatenate
Months:
load Month, MonthSeq, Quarter, SelectMonth
Resident tmpMonths
where MonthSeq&amp;lt;=SelectSeq and Quarter=SelectQuarter;

drop table tmpMonths;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 14:22:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1773727#M454741</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-12T14:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1774028#M454765</link>
      <description>&lt;P&gt;Hi Edwin,&lt;/P&gt;&lt;P&gt;Thank you very much for providing solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; It's made my day.&lt;/P&gt;&lt;P&gt;Absolutely working fine&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 12:24:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1774028#M454765</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2021-01-13T12:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: QTD calculation in Script</title>
      <link>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1774087#M454767</link>
      <description>&lt;P&gt;np&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 14:24:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/QTD-calculation-in-Script/m-p/1774087#M454767</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-01-13T14:24:45Z</dc:date>
    </item>
  </channel>
</rss>

