<?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 Chart showing previous 6 months in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391813#M486139</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 am trying to put together a line chart showing the average cost per unit for the previous 6 months, depending on the date selections made in the calendar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dimension of the chart is Cal_MonthYear (which is date(monthstart(Date), 'MM YYYY'). So if the user selects Feb-13 in the calendar, I would want the chart to show Sep-12, Oct-12, Nov-12, Dec-12, Jan-13, Feb-13.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to put together an expression along the lines of the following, but I can't get it to work;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=(sum(Cost) / sum(units))&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({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -1), 'MM YYYY'))"}&amp;gt;}Cost)&lt;/P&gt;&lt;P&gt;/ &lt;/P&gt;&lt;P&gt;(sum({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -1), 'MM YYYY'))"}&amp;gt;}Units)&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({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -2), 'MM YYYY'))"}&amp;gt;}Cost)&lt;/P&gt;&lt;P&gt;/ &lt;/P&gt;&lt;P&gt;(sum({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -2), 'MM YYYY'))"}&amp;gt;}Units)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming it must be a relatively straight-forward thing to do, but I just can't seem to get it to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Danielle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Mar 2013 09:19:03 GMT</pubDate>
    <dc:creator>danielle_v</dc:creator>
    <dc:date>2013-03-26T09:19:03Z</dc:date>
    <item>
      <title>Chart showing previous 6 months</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391813#M486139</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 am trying to put together a line chart showing the average cost per unit for the previous 6 months, depending on the date selections made in the calendar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dimension of the chart is Cal_MonthYear (which is date(monthstart(Date), 'MM YYYY'). So if the user selects Feb-13 in the calendar, I would want the chart to show Sep-12, Oct-12, Nov-12, Dec-12, Jan-13, Feb-13.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to put together an expression along the lines of the following, but I can't get it to work;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=(sum(Cost) / sum(units))&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({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -1), 'MM YYYY'))"}&amp;gt;}Cost)&lt;/P&gt;&lt;P&gt;/ &lt;/P&gt;&lt;P&gt;(sum({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -1), 'MM YYYY'))"}&amp;gt;}Units)&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({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -2), 'MM YYYY'))"}&amp;gt;}Cost)&lt;/P&gt;&lt;P&gt;/ &lt;/P&gt;&lt;P&gt;(sum({&amp;lt;Cal_MonthYear = {"$(=date(addmonths(Cal_MonthYear, -2), 'MM YYYY'))"}&amp;gt;}Units)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming it must be a relatively straight-forward thing to do, but I just can't seem to get it to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Danielle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 09:19:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391813#M486139</guid>
      <dc:creator>danielle_v</dc:creator>
      <dc:date>2013-03-26T09:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Chart showing previous 6 months</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391814#M486140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't use a calculated dimension in set analysis expressions. The set is calculated before the chart, so the calculated dimension doesn't exist yet then.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps this does what you want:&lt;/P&gt;&lt;P&gt;=(sum({&amp;lt;Date={'&amp;gt;=$(=addmonths(monthstart(max(Date)),-6))&amp;lt;$(=monthstart(max(Date)))'} &amp;gt;} Cost) / sum({&amp;lt;Date={'&amp;gt;=$(=addmonths(monthstart(max(Date)),-6))&amp;lt;$(=monthstart(max(Date)))'} &amp;gt;} Units))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, it would help if you posted the document you're working on or a representative example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 12:40:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391814#M486140</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-03-26T12:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Chart showing previous 6 months</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391815#M486141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think I worded my question very well - what I meant was that the dimension Cal_MonthYear is calculated in the script as date(monthstart(Date), 'MM YYYY'). It's not a calculated dimension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried your above suggestion but can't get it to work. When you state Date, do you mean my date field (i.e. Cal_MonthYear)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Danielle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 16:00:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391815#M486141</guid>
      <dc:creator>danielle_v</dc:creator>
      <dc:date>2013-03-26T16:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Chart showing previous 6 months</title>
      <link>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391816#M486142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, ok. Yeah, in that case use Cal_MonthYear instead of Date. monthstart won't be needed either since you already used that in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=(sum({&amp;lt;Cal_MonthYear={'&amp;gt;$(=addmonths(only(Cal_MonthYear),-6))&amp;lt;=$(=only(Cal_MonthYear))'} &amp;gt;} Cost) / sum({&amp;lt;Cal_MonthYear={'&amp;gt;$(=addmonths(only(Cal_MonthYear),-6))&amp;lt;=$(=only(Cal_MonthYear))'} &amp;gt;} Units))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 17:15:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Chart-showing-previous-6-months/m-p/391816#M486142</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-03-26T17:15:16Z</dc:date>
    </item>
  </channel>
</rss>

