<?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 Set Analysis - addmonths in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170153#M40671</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That expression did work when one monthyear is selected but your right it still isn't working for mulitiple months.&lt;/P&gt;&lt;P&gt;I tried adding a new expression LY to the chart and it is showing the same month last year.&lt;/P&gt;&lt;P&gt;=date(addmonths(MonthYear,-12),'MMM-YYYY')&lt;/P&gt;&lt;P&gt;Then changed the counter to&lt;/P&gt;&lt;P&gt;=count(total distinct {$&amp;lt; MonthYear={"[LY]"} &amp;gt;} Counter)&lt;/P&gt;&lt;P&gt;But that isn't working. Do you know if it is possible to add an expression to set analysis in another expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Aug 2010 17:09:18 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-08-20T17:09:18Z</dc:date>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170151#M40669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Guys,&lt;/P&gt;&lt;P&gt;What I'm trying to do is count for the same month in a table for last year. For example, if Jan-2010 and Feb 2010 are selected the table will display like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 191pt; border-collapse: collapse;" width="255"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 105pt; mso-width-source: userset; mso-width-alt: 5120; mso-outline-parent: collapsed;" width="140" /&gt;&lt;COL style="width: 38pt; mso-width-source: userset; mso-width-alt: 1865; mso-outline-parent: collapsed;" width="51" /&gt;&lt;COL style="width: 48pt;" width="64" /&gt;&lt;/COLGROUP&gt;&lt;TBODY&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD class="xl63" height="17" style="background-color: transparent; width: 105pt; height: 12.75pt; border: #ece9d8;" width="140"&gt;&lt;STRONG&gt;MonthYear&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl64" style="background-color: transparent; width: 38pt; border: #ece9d8;" width="51"&gt;This Year&lt;/TD&gt;&lt;TD class="xl64" style="background-color: transparent; width: 48pt; border: #ece9d8;" width="64"&gt;Last Year&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD class="xl64" height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;Jan-2010&lt;/TD&gt;&lt;TD align="right" class="xl64" style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8"&gt;120&lt;/TD&gt;&lt;TD align="right" class="xl64" style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8"&gt;95&lt;/TD&gt;&lt;/TR&gt;&lt;TR height="17" style="height: 12.75pt;"&gt;&lt;TD class="xl64" height="17" style="background-color: transparent; height: 12.75pt; border: #ece9d8;"&gt;Feb-2010&lt;/TD&gt;&lt;TD align="right" class="xl64" style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8"&gt;200&lt;/TD&gt;&lt;TD align="right" class="xl64" style="BORDER-BOTTOM: #ece9d8; BORDER-LEFT: #ece9d8; BACKGROUND-COLOR: transparent; BORDER-TOP: #ece9d8; BORDER-RIGHT: #ece9d8"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;I'm having troubles getting this expression to work&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=count(total distinct {$&amp;lt; MonthYear={"=date(addmonths(MonthYear,-12),'MMM-YYYY')"} &amp;gt;} Counter)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If I use the expression below it will work for Jan. So, I'm not sure why the above one isn't working.&lt;/P&gt;&lt;P&gt;=count(total distinct {$&amp;lt;MonthYear={"Jan-2009"}&amp;gt;} %[Buying_Store_Counter])&lt;/P&gt;&lt;P&gt;I also tried setting a variable vDateLY to&lt;/P&gt;&lt;P&gt;=date(addmonths(MonthYear,-12),'MMM-YYYY')&lt;/P&gt;&lt;P&gt;And then set the expression to&lt;/P&gt;&lt;P&gt;=count(total distinct {$&amp;lt; MonthYear={'$(=vDateLY)'} &amp;gt;} %[Buying_Store_Counter])&lt;/P&gt;&lt;P&gt;That works but only when one month is selected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 16:52:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170151#M40669</guid>
      <dc:creator />
      <dc:date>2010-08-20T16:52:12Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170152#M40670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You probably need a dollar sign expansion to get the AddMonths function to work. Something like:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;=count(total distinct {$&amp;lt; MonthYear=&lt;BR /&gt;{"$(=date(addmonths(MonthYear,-12),'MMM-YYYY'))"} &amp;gt;} Counter)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Put that expression into a chart without a label. When the chart is rendered, the label will be your expression with the dollar sign expansion evaluated. Dates are tough, because formatting can be an issue. This will tell you the result of your function and you should compare it to your version with the hardcoded date.&lt;/P&gt;&lt;P&gt;I still don't know if that's going to get you the result you're looking for, because it will not be based on the dimension. The dollar sign expansion is evaluated once for the entire chart, not for every record. EDIT: Here is a previous discussion that talks about a similar issue and offers some solutions: &lt;A href="http://community.qlik.com/forums/t/23889.aspx"&gt;http://community.qlik.com/forums/t/23889.aspx&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 17:00:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170152#M40670</guid>
      <dc:creator />
      <dc:date>2010-08-20T17:00:44Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170153#M40671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That expression did work when one monthyear is selected but your right it still isn't working for mulitiple months.&lt;/P&gt;&lt;P&gt;I tried adding a new expression LY to the chart and it is showing the same month last year.&lt;/P&gt;&lt;P&gt;=date(addmonths(MonthYear,-12),'MMM-YYYY')&lt;/P&gt;&lt;P&gt;Then changed the counter to&lt;/P&gt;&lt;P&gt;=count(total distinct {$&amp;lt; MonthYear={"[LY]"} &amp;gt;} Counter)&lt;/P&gt;&lt;P&gt;But that isn't working. Do you know if it is possible to add an expression to set analysis in another expression.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 17:09:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170153#M40671</guid>
      <dc:creator />
      <dc:date>2010-08-20T17:09:18Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170154#M40672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That won't work, because the Set Modifier part won't be evaluated record by record. Is the date one of your dimensions in the chart?&lt;/P&gt;&lt;P&gt;I've found the easiest way (for me) to handle this is by including some of this information in the load. In one application, we load a separate set of fact fields for the previous year. For each record, we have Sales and PY Sales, that way, we just add each field to the table.&lt;/P&gt;&lt;P&gt;You could also use an if...then:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;=count(total distinct If(MonthYear=date(addmonths(MonthYear,-12),'MMM-YYYY'), Counter))&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Are your users selecting a year to display on the chart? Set Analysis works great with selections or across the entire data set, but not on a record by record level. If the user is making a selection of the current year, then you can do something like:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;=count(total distinct {1&amp;lt;Year = {$(=Max(Year)-1)}&amp;gt;} Counter)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Or, if the current year is always the current year (Current Year is the Max(Year) in your data set), then the above expression should work without the 1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 17:21:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170154#M40672</guid>
      <dc:creator />
      <dc:date>2010-08-20T17:21:08Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170155#M40673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeh, you are right. I'm going to have to load a separte set.&lt;/P&gt;&lt;P&gt;I hate to bug you more but can you go into more details on how you did that.&lt;/P&gt;&lt;P&gt;My fact table is&lt;/P&gt;&lt;P&gt;FactTable:&lt;BR /&gt;Load&lt;BR /&gt; FactKey,&lt;BR /&gt; SaleDate,&lt;BR /&gt; Product,&lt;BR /&gt; Customer,&lt;BR /&gt; Price,&lt;BR /&gt; Counter&lt;BR /&gt;From sales.qvd (qvd);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 17:50:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170155#M40673</guid>
      <dc:creator />
      <dc:date>2010-08-20T17:50:19Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170156#M40674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this may work:&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;FactTable:&lt;BR /&gt;Load&lt;BR /&gt; FactKey,&lt;BR /&gt; SaleDate,&lt;BR /&gt; Product,&lt;BR /&gt; Customer,&lt;BR /&gt; Price,&lt;BR /&gt; Counter&lt;BR /&gt;From sales.qvd (qvd);&lt;BR /&gt;Join Load&lt;BR /&gt; AddMonths(SaleDate, 12) As SaleDate,&lt;BR /&gt; Product,&lt;BR /&gt; Customer,&lt;BR /&gt; Price As PY_Price,&lt;BR /&gt; Counter As PY_Counter&lt;BR /&gt;From sales.qvd (qvd);&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;That should load all your current data is normal. The second part adds one year to the sales date (so the previous year values get the current year SaleDate). The two tables will be joined on SaleDate, Customer and Product. I don't know if that is exactly what you need, but that's the basic idea.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 18:07:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170156#M40674</guid>
      <dc:creator />
      <dc:date>2010-08-20T18:07:34Z</dc:date>
    </item>
    <item>
      <title>Set Analysis - addmonths</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170157#M40675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are awesome. That worked like a champ.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 19:41:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-addmonths/m-p/170157#M40675</guid>
      <dc:creator />
      <dc:date>2010-08-20T19:41:46Z</dc:date>
    </item>
  </channel>
</rss>

