<?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: Display a dynamic last 12 months in a line chart? in Visualization and Usability</title>
    <link>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1998129#M217221</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN&gt;Mayil&lt;/SPAN&gt;! I was able to achieve my goal by taking an approach similar to what you outlined above, just with the use of variables. See below for what I did:&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create variable vMaxDate, definition:&amp;nbsp;=Date(Max(&lt;EM&gt;YourDateField&lt;/EM&gt;))&lt;/LI&gt;
&lt;LI&gt;Create variable vR12_Start, definition: Date(Floor(MonthStart(AddMonths(vMaxDate,-12))))&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vMonthEnd, definition:&amp;nbsp;Date(Floor(MonthEnd(vMaxDate)))&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vIgnoreTimeLine, definition: ='&lt;EM&gt;YourDateField1=, YourDatefield2=, YourDateField3='&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vR12_Set, definition: '&lt;EM&gt;YourDateField&lt;/EM&gt;= {"&amp;gt;='&amp;amp;$(vR12_Start)&amp;amp;'"}*{"&amp;lt;='&amp;amp;$(vMonthEnd)&amp;amp;'"},'&amp;amp;vIgnoreTimeLine&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT face="inherit"&gt;Then, for whatever measure you are constraining by&amp;nbsp;&lt;/FONT&gt;the rolling 12 months can be written like:&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;sum({$&amp;lt;$(=$(vR12_Set))&amp;gt;}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &lt;EM&gt;YourMeasure&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; )&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Oct 2022 14:12:05 GMT</pubDate>
    <dc:creator>rduregger</dc:creator>
    <dc:date>2022-10-28T14:12:05Z</dc:date>
    <item>
      <title>Display a dynamic last 12 months in a line chart?</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1992009#M216161</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am developing a line chart where I will need to display the last 12 months on the X axis. The field I need to use for this, &amp;nbsp;DateField, &amp;nbsp;is a timestamp ('M/D/YYYY h:mm:ss TT', &amp;nbsp;e.g.&amp;nbsp;1/1/2018 11:04:35 AM) in the data model.&lt;/P&gt;
&lt;P&gt;Ideally, the chart will default to the last 12 months relative to the present day's date (e.g., if today is 12 October 2022, it will show data for 12 October 2022 thru 12 October 2021). Additionally, it should respond to a user selection on the date field (e.g., user selects 16 July 2022 and the chart updates to show 16 July 2022 thru 16 July 2021).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While I've read similar posts to this forum, I haven't come across a post yet where I can tailor the solution to my needs. Would anyone be able to point me in the right direction in terms of scripting required for this? Happy to share additional explanation to the requirements and also include sample data, if helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 01:56:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1992009#M216161</guid>
      <dc:creator>rduregger</dc:creator>
      <dc:date>2022-10-13T01:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Display a dynamic last 12 months in a line chart?</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1992015#M216163</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;We can bring datefield without timestamp from data model and then try like below&lt;/P&gt;
&lt;P&gt;Sum({&lt;STRONG&gt;&amp;lt;Date={"&amp;gt;=$(=AddMonths(Max(Date),-12))&amp;lt;=$(=Date(Max(Date)))"},MonthYear=, Year=, Month=, Quarter=&amp;gt;}&lt;/STRONG&gt;urmeasure)&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 02:34:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1992015#M216163</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2022-10-13T02:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Display a dynamic last 12 months in a line chart?</title>
      <link>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1998129#M217221</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN&gt;Mayil&lt;/SPAN&gt;! I was able to achieve my goal by taking an approach similar to what you outlined above, just with the use of variables. See below for what I did:&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create variable vMaxDate, definition:&amp;nbsp;=Date(Max(&lt;EM&gt;YourDateField&lt;/EM&gt;))&lt;/LI&gt;
&lt;LI&gt;Create variable vR12_Start, definition: Date(Floor(MonthStart(AddMonths(vMaxDate,-12))))&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vMonthEnd, definition:&amp;nbsp;Date(Floor(MonthEnd(vMaxDate)))&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vIgnoreTimeLine, definition: ='&lt;EM&gt;YourDateField1=, YourDatefield2=, YourDateField3='&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create variable vR12_Set, definition: '&lt;EM&gt;YourDateField&lt;/EM&gt;= {"&amp;gt;='&amp;amp;$(vR12_Start)&amp;amp;'"}*{"&amp;lt;='&amp;amp;$(vMonthEnd)&amp;amp;'"},'&amp;amp;vIgnoreTimeLine&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;FONT face="inherit"&gt;Then, for whatever measure you are constraining by&amp;nbsp;&lt;/FONT&gt;the rolling 12 months can be written like:&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;sum({$&amp;lt;$(=$(vR12_Set))&amp;gt;}&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &lt;EM&gt;YourMeasure&lt;/EM&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; )&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 14:12:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Visualization-and-Usability/Display-a-dynamic-last-12-months-in-a-line-chart/m-p/1998129#M217221</guid>
      <dc:creator>rduregger</dc:creator>
      <dc:date>2022-10-28T14:12:05Z</dc:date>
    </item>
  </channel>
</rss>

