<?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: AddMonths function to vStartDate - selecting arbitrary date ranges in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063865#M355836</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #575757; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Can you try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #575757;"&gt;&lt;STRONG&gt;=Sum({$&amp;lt;Month_YYYY={"&amp;gt;=&lt;SPAN style="color: #ff0000;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#('$(vStartDate)','MMM-YYYY'), -12), 'MMM-YYYY')&amp;lt;=&lt;SPAN style="color: #ff0000;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#('$(vEndDate)', 'MMM-YYYY'), -12), 'MMM-YYYY')"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style=": ; color: #575757; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;}&amp;gt;}Revenue)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This won't work if you have Month_YYYY as your dimension. In that case you will need to use Above() or Below() functions based on your sorting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Mar 2016 17:47:59 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-03-01T17:47:59Z</dc:date>
    <item>
      <title>AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063864#M355835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been asked to create an app for revenue reporting that allows the end user to input the data ranges the user wants to view - I watched the "Selecting Arbitrary date ranges" video on YouTube, and added the functionality to the app.&amp;nbsp; I was extremely happy with this, and so was the chap who requested the app in the first place - but now he's asked for a prior period comparative which shows the previous year to the arbitrary date ranges selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The formula to show the revenue for the period selected by the user I have created is this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;Month_YYYY={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"&amp;gt;=vStartDate&amp;lt;=vEndDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}Revenue) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Having had a think about it, I think AddMonths is the right way to go with this, so I came up with this formula:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({$&amp;lt;Month_YYYY={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"&amp;gt;=(date(addmonths(Date#('$(vStartDate)','MMM-YYYY'),-12),'MMM-YYYY')&amp;lt;=(date(addmonths(Date#('$(vEndDate)','MMM-YYYY'),-121),'MMM-YYYY')"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}Revenue) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;What I'm expecting to see is if the user selected Jan-2015 as the start date and May-2015 as the end date, the sum of Revenue for Jan-2014 to May-2014.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Depressingly though, I'm seeing the exact same value as for the first formula.&amp;nbsp; I've spent the past four hours moving single quotes and double quotes around and adding and removing brackets, and I'm utterly at a loss now. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Can anyone help me figure out where I'm going wrong? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks in advance&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Lisa&lt;/SPAN&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>Tue, 01 Mar 2016 17:19:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063864#M355835</guid>
      <dc:creator />
      <dc:date>2016-03-01T17:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063865#M355836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #575757; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;Can you try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #575757;"&gt;&lt;STRONG&gt;=Sum({$&amp;lt;Month_YYYY={"&amp;gt;=&lt;SPAN style="color: #ff0000;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#('$(vStartDate)','MMM-YYYY'), -12), 'MMM-YYYY')&amp;lt;=&lt;SPAN style="color: #ff0000;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#('$(vEndDate)', 'MMM-YYYY'), -12), 'MMM-YYYY')"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style=": ; color: #575757; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;}&amp;gt;}Revenue)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This won't work if you have Month_YYYY as your dimension. In that case you will need to use Above() or Below() functions based on your sorting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Mar 2016 17:47:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063865#M355836</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-03-01T17:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063866#M355837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sunny - tried it, but no change.&amp;nbsp; I'm not using Month_YYYY as a dimension, only client names.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 09:36:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063866#M355837</guid>
      <dc:creator />
      <dc:date>2016-03-02T09:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063867#M355838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #0000ff;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;({$&amp;lt;Month_YYYY={&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #800000;"&gt;"&amp;gt;=$(=date(addmonths(Date#('$(vStartDate)','MMM-YYYY'),-12),'MMM-YYYY')&amp;lt;=$(=date(addmonths(Date#('$(vEndDate)','MMM-YYYY'),-12),'MMM-YYYY')"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;}&amp;gt;} Revenue)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 09:47:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063867#M355838</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-03-02T09:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063868#M355839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tried that one too - no change.&amp;nbsp; Thanks for replying though!&amp;nbsp; Very much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 10:12:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063868#M355839</guid>
      <dc:creator />
      <dc:date>2016-03-02T10:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063869#M355840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #575757; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;What about if you remove single quotes from around your variables:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif; font-size: 10pt; color: #575757;"&gt;&lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;=Sum({$&amp;lt;Month_YYYY={"&amp;gt;=&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#($(vStartDate),'MMM-YYYY'), -12), 'MMM-YYYY')&amp;lt;=&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#($(vEndDate), 'MMM-YYYY'), -12), 'MMM-YYYY')"&lt;/STRONG&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;}&amp;gt;}Revenue)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;or removing both the single quote and dollar sign expansion&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif; color: #575757;"&gt;&lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;=Sum({$&amp;lt;Month_YYYY={"&amp;gt;=&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#(vStartDate,'MMM-YYYY'), -12), 'MMM-YYYY')&amp;lt;=&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;$&lt;/SPAN&gt;(Date(AddMonths(Date#(vEndDate, 'MMM-YYYY'), -12), 'MMM-YYYY')"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style=": ; color: #575757; font-style: inherit; font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;}&amp;gt;}Revenue)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 15:20:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063869#M355840</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-03-02T15:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: AddMonths function to vStartDate - selecting arbitrary date ranges</title>
      <link>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063870#M355841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, so I have a solution to this - but using addmonths in the set analysis wouldn't work, no matter what variation of dollar expansion, single quotes or double quotes I tried!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the end, I set two additional variables - based off my vStartDate and vEndDate, and applied the addmonths function to them: &lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;addmonths&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('$(vStartDate)', -12) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works perfectly.&amp;nbsp; Thanks Sunny and Balraj for your help though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 10:12:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AddMonths-function-to-vStartDate-selecting-arbitrary-date-ranges/m-p/1063870#M355841</guid>
      <dc:creator />
      <dc:date>2016-03-07T10:12:03Z</dc:date>
    </item>
  </channel>
</rss>

