<?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 Using variables and functions in set analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221172#M74006</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But I would prefer to simplify this problem 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;Variable:&lt;BR /&gt;Let vSelectedDate = Date#(CALENDER_MONTH &amp;amp; '.' &amp;amp; CALENDER_YEAR,'MM.YYYY');&lt;BR /&gt;Expression:&lt;BR /&gt;=Sum({&amp;lt;DATE={"&amp;gt;=$(=MonthStart(vSelectedDate,-12)) &amp;lt;=$(=MonthEnd(vSelectedDate))"}&amp;gt;} SALES)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;You might need to play a bit with the date formats to get this to work. DATE and MonthStart/MonthEnd must all be in the same date format.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Sep 2010 20:45:27 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2010-09-28T20:45:27Z</dc:date>
    <item>
      <title>Using variables and functions in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221169#M74003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to calculate a running total of 12 month SALES in my application based on the selected year and month.&lt;/P&gt;&lt;P&gt;For this purpose I have created to variables (to make expression a bit more simple):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vSelectionMonthEnd = monthend(date#('01.' &amp;amp; CALENDER_MONTH &amp;amp; '.' &amp;amp; CALENDER_YEAR,'DD.MM.YYYY'))&lt;/P&gt;&lt;P&gt;-&amp;gt; This variable holds the month end date of current selected monht and year.&lt;/P&gt;&lt;P&gt;vSelectionBeginRegion = monthstart(addmonths(monthend(date#('01.'&amp;amp;CALENDER_MONTH &amp;amp; '.' &amp;amp; CALENDER_YEAR,'DD.MM.YYYY')),-11))&lt;/P&gt;&lt;P&gt;-&amp;gt; This variable holds the start date of 12 months before.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;I have following expression in my straight table:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;DATE={"&amp;gt;=$(#vSelectionBeginRegion) &amp;lt;=$(#vSelectionMonthEnd)"}&amp;gt;} SALES)&lt;/P&gt;&lt;P&gt;This seems to work fine.&lt;/P&gt;&lt;P&gt;Now I would like to show also running 12 months sales for previous month, in other words: if SEP-2010 is selected, expression above will sum sales for 1.10.2009 - 30.9.2010. Next column should show running 12 month total for AUG-2010 (SEP-2010 still selected...), that is sales for period 1.9.2009 - 31.8.2010.&lt;/P&gt;&lt;P&gt;To get this, I add a new expression in my straight table:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;DATE={"&amp;gt;=AddMonths($(#vSelectionBeginRegion),-1) &amp;lt;= AddMonths($(#vSelectionMonthEnd),-1)"}&amp;gt;} SALES)&lt;/P&gt;&lt;P&gt;This expression returns zero, which is not correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas how to get the later expression to work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-- Jussi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Sep 2010 19:23:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221169#M74003</guid>
      <dc:creator />
      <dc:date>2010-09-28T19:23:55Z</dc:date>
    </item>
    <item>
      <title>Using variables and functions in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221170#M74004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm guessing the AddMonths function is changing the format of your date. Try doing Date(AddMonths(var, -1), 'DateFormatNeeded')&lt;/P&gt;&lt;P&gt;One way to check this is to create a straight table. Add your second expression, but don't give it a label. Then, when the chart is rendered, the label will be your expression with the dollar sign expansion evaluated. If you add both of your expressions, I bet the date format will differ on them (the second one may even show a number rather than a date).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Sep 2010 20:05:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221170#M74004</guid>
      <dc:creator />
      <dc:date>2010-09-28T20:05:20Z</dc:date>
    </item>
    <item>
      <title>Using variables and functions in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221171#M74005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I would try&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;=sum({&amp;lt;DATE={"&amp;gt;=$(=AddMonths(vSelectionBeginRegion,-1)) &amp;lt;=$(=AddMonths(vSelectionMonthEnd,-1))"}&amp;gt;} SALES)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Sep 2010 20:34:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221171#M74005</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2010-09-28T20:34:45Z</dc:date>
    </item>
    <item>
      <title>Using variables and functions in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221172#M74006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But I would prefer to simplify this problem 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;Variable:&lt;BR /&gt;Let vSelectedDate = Date#(CALENDER_MONTH &amp;amp; '.' &amp;amp; CALENDER_YEAR,'MM.YYYY');&lt;BR /&gt;Expression:&lt;BR /&gt;=Sum({&amp;lt;DATE={"&amp;gt;=$(=MonthStart(vSelectedDate,-12)) &amp;lt;=$(=MonthEnd(vSelectedDate))"}&amp;gt;} SALES)&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;You might need to play a bit with the date formats to get this to work. DATE and MonthStart/MonthEnd must all be in the same date format.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Sep 2010 20:45:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221172#M74006</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2010-09-28T20:45:27Z</dc:date>
    </item>
    <item>
      <title>Using variables and functions in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221173#M74007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jonathan, this one solved the problem!&lt;/P&gt;&lt;P&gt;-- Jussi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Sep 2010 10:27:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-variables-and-functions-in-set-analysis/m-p/221173#M74007</guid>
      <dc:creator />
      <dc:date>2010-09-29T10:27:41Z</dc:date>
    </item>
  </channel>
</rss>

