<?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 date calculation based on number of days in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150738#M28705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To accurately display Sales vs Budget values. I have to annualize budget numbers.Sales is loaded daily by invoice date, but Budget is reported monthly.&lt;/P&gt;&lt;P&gt;I will need to calculate Budget/days in month * current day -1&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Budget amount for July is 28075&lt;/P&gt;&lt;P&gt;28075/31*29 = 26,263.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please help me with the correct syntax to calculate this formula. I still have trouble using all the date fucntions in QV.&lt;/P&gt;&lt;P&gt;Do I need to use a variable? Currently, we do not have any variable is our application. How can I dynamically handle the different amount of days in a month and calculated based on previous day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I currently use YTD flags based on our fiscal/gregorian calendar. I would need to result with chart planvalue calculation below.&lt;/P&gt;&lt;P&gt;Can someone please advise how should handle this in the script and/or chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;(SALESVALUE * FY_YTD_Flag)/Sum(PLANVALUE * FY_YTD_Flag)&lt;/P&gt;&lt;P&gt;Planvalue= budget value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jul 2009 21:23:58 GMT</pubDate>
    <dc:creator>karensmith</dc:creator>
    <dc:date>2009-07-30T21:23:58Z</dc:date>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150738#M28705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To accurately display Sales vs Budget values. I have to annualize budget numbers.Sales is loaded daily by invoice date, but Budget is reported monthly.&lt;/P&gt;&lt;P&gt;I will need to calculate Budget/days in month * current day -1&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Budget amount for July is 28075&lt;/P&gt;&lt;P&gt;28075/31*29 = 26,263.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please help me with the correct syntax to calculate this formula. I still have trouble using all the date fucntions in QV.&lt;/P&gt;&lt;P&gt;Do I need to use a variable? Currently, we do not have any variable is our application. How can I dynamically handle the different amount of days in a month and calculated based on previous day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I currently use YTD flags based on our fiscal/gregorian calendar. I would need to result with chart planvalue calculation below.&lt;/P&gt;&lt;P&gt;Can someone please advise how should handle this in the script and/or chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;(SALESVALUE * FY_YTD_Flag)/Sum(PLANVALUE * FY_YTD_Flag)&lt;/P&gt;&lt;P&gt;Planvalue= budget value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 21:23:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150738#M28705</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-30T21:23:58Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150739#M28706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to add that we also calculate LY YTD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 21:50:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150739#M28706</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-30T21:50:52Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150740#M28707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to use this formula when 30 days is hard coded, but I actually need to calculate the number of days in the month:&lt;/P&gt;&lt;P&gt;Sum(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(PLANVALUE* FY_YTD_Flag)/30)* (date(today())-date(monthstart(today())))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can I handle the days in a month calculation?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 22:42:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150740#M28707</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-30T22:42:55Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150741#M28708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Okay... I'm actually beginning to answer my own questions, but continue to run into road blocks.&lt;/P&gt;&lt;P&gt;Sum&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(PLANVALUE* FY_YTD_Flag)/((ROUND(monthend(TODAY())-monthstart(TODAY())))) * (date(today())-date(monthstart(today())))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine when looking at YTD. But when user wants to compare LY YTD as of the same date. This formula is not correct because the day calculations are going to be based on the current day and current month.&lt;/P&gt;&lt;P&gt;Can someone please help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to show object that shows Sales vs Budget YTD and Sales Vs Budget LY YTD. Budget is calculated on days in month * days that have passed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is my logic incorrect? does it makes sense to make this type of comparison? Or should LY YTD be the complete month values?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 00:00:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150741#M28708</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-31T00:00:55Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150742#M28709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Karen,&lt;/P&gt;&lt;P&gt;you are on the right path, only you could simplify your expressions a lot if you could pre-calculate some flags in your script.There are many ways of approaching this problem, here is one:&lt;/P&gt;&lt;P&gt;Pre-calculate the field "YTD Monthly Multiplier" and link it to the field Year/Month in your calendar:&lt;/P&gt;&lt;P&gt;- for all YTD Year/Month values, except for the current month, the Multiplier should be 1.&lt;/P&gt;&lt;P&gt;- for the CUrrent Month (including PY Current Month), the Multiplier = &amp;lt;number of days that passed till today&amp;gt; / &amp;lt;number of days in the current month&amp;gt;&lt;/P&gt;&lt;P&gt;- for all the months beyond today, the Multiplier should be equal to 0.&lt;/P&gt;&lt;P&gt;After loading a field into your Claendar table, your expression for YTD Budget will be very simple:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YTDBudget = sum(Budget*YTD_Flag*YTD_Multiplier)&lt;/P&gt;&lt;P&gt;PY_YTD_Budget = sum(Budget*PY_YTD_Flag*YTD_Multiplier)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good luck!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oleg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV id="refHTML"&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 01:43:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150742#M28709</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2009-07-31T01:43:45Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150743#M28710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Oleg,&lt;/P&gt;&lt;P&gt;This is my calendar load statement. I started using YTD flags for both our FY year and Gregorian Year. Calculations were working great, until it dawned on me that when comparing back to previous year would not truly current year's YTD time period.&lt;/P&gt;&lt;P&gt;Are you saying to completely scrap my previous calculations-use flags and multipliers and then your new code fir YTD budget ad PY_YTD_Budget on the object?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Year(DATE([Fiscal Year],'YYYY')) &lt;B&gt;as&lt;/B&gt; FYYear,&lt;/P&gt;&lt;P&gt;fiscalQuarter&lt;/P&gt;&lt;P&gt;,CalendarQuarter&lt;/P&gt;&lt;P&gt;Year2Date(CalendarDate,0,4) * -1 &lt;B&gt;as&lt;/B&gt; FY_YTD_Flag&lt;/P&gt;&lt;P&gt;,Year2Date(CalendarDate, -1,4) * -1 &lt;B&gt;as&lt;/B&gt; FY_LY_YTD_Flag&lt;/P&gt;&lt;P&gt;,Year2Date(CalendarDate) * -1 &lt;B&gt;as&lt;/B&gt; CAL_YTD_Flag&lt;/P&gt;&lt;P&gt;,Year2Date(CalendarDate,-1) * -1 &lt;B&gt;as&lt;/B&gt; CAL_LY_YTD_Flag&lt;/P&gt;&lt;P&gt;,Year(DATE([Calendar Year],'YYYY')) &lt;B&gt;as&lt;/B&gt; CalYear&lt;/P&gt;&lt;P&gt;,date((CalendarDate),'MM/DD/YY') &lt;B&gt;as&lt;/B&gt; INVOICE_DATE&lt;/P&gt;&lt;P&gt;,date((CalendarDate),'MM/DD/YY') &lt;B&gt;as&lt;/B&gt; INVDT&lt;/P&gt;&lt;P&gt;,date(monthstart(num(CalendarMonthYear)),'MMYYYY') &lt;B&gt;as&lt;/B&gt; MONTHYEAR&lt;/P&gt;&lt;P&gt;,num(Month) &lt;B&gt;as&lt;/B&gt; FYMonth&lt;/P&gt;&lt;P&gt;from excel spreadsheet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"YTD Monthly Multiplier"- will this be a seperate table when you say "link it to field Year/Month"???? Or do I need to preceding load?? Just to confirm I am onl creating one field, but adding two flags? Can I use the flags that I already have and make YTD modifiier from MonthYear field.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Does this mean I create a new field in calendar load - date(monthstart(num(CalendarMonthYear)),'MMYYYY') &lt;B&gt;* 1 as YTD Monthly Mulitplier&lt;/B&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;I will go ahead an try to attack this. What you have suggested seems to make alot of sense. When calculating number of days passed/number of days in the current month? Should I use my original formula?&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 02:31:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150743#M28710</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-31T02:31:30Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150744#M28711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;Updated load script with new flag calculations, but I'm still confused on how to "Pre-calculate the field "YTD Monthly Multiplier" and link it to the field Year/Month in your calendar"&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;LOAD&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;DISTINCT&lt;/P&gt;&lt;P&gt;Year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(DATE([Fiscal Year],'YYYY')) &lt;B&gt;as&lt;/B&gt; FYYear&lt;/P&gt;&lt;P&gt;FiscalQuarter&lt;/P&gt;&lt;P&gt;,CalendarQuarter&lt;/P&gt;&lt;P&gt;Year2Date(CalendarDate,0,4) * 1 &lt;B&gt;as&lt;/B&gt; FY_YTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year2Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CalendarDate, -1,4) * 1 &lt;B&gt;as&lt;/B&gt; FY_LY_YTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year2Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(month((CalendarDate,0,4))) *1 &lt;B&gt;as&lt;/B&gt; FY_MTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year2Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(month((CalendarDate,0,4))) *1 &lt;B&gt;as&lt;/B&gt; FY_LY_MTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(num(FYMonth) &amp;gt; num(month(today()),num(month(today())))*0) &lt;B&gt;as&lt;/B&gt; future_mth_flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(num(FYMonth) &amp;lt; num(month(today())),num(month(today()))*1 )&lt;B&gt;as&lt;/B&gt; FlagMonth&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(num(FYMonth) = num(month(today())),num(FYMonth)*(date(today())-date(monthstart(today()))/ ,((ROUND(monthend(TODAY())-monthstart(TODAY())))),0)) &lt;B&gt;as&lt;/B&gt; CurrentMonghFlag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year2Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CalendarDate) * -1 &lt;B&gt;as&lt;/B&gt; CAL_YTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year2Date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(CalendarDate,-1) * -1 &lt;B&gt;as&lt;/B&gt; CAL_LY_YTD_Flag&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Year&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(DATE([Calendar Year],'YYYY')) &lt;B&gt;as&lt;/B&gt; CalYear&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;((CalendarDate),'MM/DD/YY') &lt;B&gt;as&lt;/B&gt; INVOICE_DATE&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;((CalendarDate),'MM/DD/YY') &lt;B&gt;as&lt;/B&gt; INVDT&lt;/P&gt;&lt;P&gt;,date(monthstart(num(CalendarMonthYear)),'MMYYYY') &lt;B&gt;as&lt;/B&gt; MONTHYEAR,&lt;/P&gt;&lt;P&gt;num&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Month) &lt;B&gt;as&lt;/B&gt;&lt;/P&gt;&lt;P&gt;FYMonth&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;FROM&lt;/P&gt;&lt;B&gt;&lt;/B&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;.. \EXCEL\Fiscal_Calendar_v2.xls (biff, embedded labels, table is Sheet1$) &lt;P&gt;;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 03:31:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150744#M28711</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-31T03:31:22Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150745#M28712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Karen,&lt;/P&gt;&lt;P&gt;You might have to load your Calendar, then perform some calculations, and then reload the calendar again with the new flag.&lt;/P&gt;&lt;P&gt;Since you have both Fiscal Periods and Calendar Months, you need to decide what to use for budget pro-rated calculation. It's a bit easier to do with Calendar Months, but if your Budget is stored based on Fiscal Calendar, you have to stick to Fiscal then.&lt;/P&gt;&lt;P&gt;The way I'd approach it is this. Before your Load statement, you need to calculated a few variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create a variable for "Current FP".&lt;/P&gt;&lt;P&gt;2. Create a variable and calculate number of days in your Current Fiscal Period.&lt;/P&gt;&lt;P&gt;3. Create another variable and calculated number of days that passed since the beginning of the Fiscal Period.&lt;/P&gt;&lt;P&gt;4. Create the final Multiplier variable by dividing the numbers of days above. Let's say you called it "vMult".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, in your load, you can do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;if( FY_LY_YTD_Flag = 0 and FY_YTD_Flag = 0, 0 , // if not YTD and not Prior YTD, then 0&lt;BR /&gt; if(FY_LY_MTD_Flag = 1 or FY_MTD_Flag = 1, $(vMult) // IF MTD or Prior Year MTD - use calculated multiplier&lt;BR /&gt; 1)) // For all other YTD or PY YTD dates - use 1 (full budget without pro-rating)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it makes sense...&lt;/P&gt;&lt;P&gt;Oleg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 04:58:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150745#M28712</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2009-07-31T04:58:43Z</dc:date>
    </item>
    <item>
      <title>date calculation based on number of days</title>
      <link>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150746#M28713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again Oleg,&lt;/P&gt;&lt;P&gt;I've tried, did not get expected results. Variables created correctly, but the MTD and CY and PY numbers are monthly grand totals, rather than using ratio. Don't know what I'm doing wrong.&lt;/P&gt;&lt;P&gt;I have attached script file. Maybe you can take a look. Thanks......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2009 09:52:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/date-calculation-based-on-number-of-days/m-p/150746#M28713</guid>
      <dc:creator>karensmith</dc:creator>
      <dc:date>2009-07-31T09:52:14Z</dc:date>
    </item>
  </channel>
</rss>

