<?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: Macro  to select latest 25 months in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990665#M337555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this isn't a good idea then everything what you could to do within the gui including actions shouldn't be done per macro, see: &lt;A href="https://community.qlik.com/qlik-blogpost/3700"&gt;Macros are Bad&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the search-expression within your OnOpen action worked it's ok. if not you could consider to simplify such search-expression with an additionally field MonthCounter, here an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/message/563904"&gt;Re: Howto make a variable to calculate quarters regarding year changes?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Nov 2015 09:30:33 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2015-11-13T09:30:33Z</dc:date>
    <item>
      <title>Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990664#M337554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to replace one of the on open triggers with macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone tell me how to write a macro to select latest 25 months.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below does not work &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;Activedocument.Evaluate("=&lt;/SPAN&gt;date(AddMonths(date#(max(DATA_FIELD),'YYYYMM'),-24),'YYYYMM')")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Khushboo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 07:57:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990664#M337554</guid>
      <dc:creator />
      <dc:date>2015-11-13T07:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990665#M337555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this isn't a good idea then everything what you could to do within the gui including actions shouldn't be done per macro, see: &lt;A href="https://community.qlik.com/qlik-blogpost/3700"&gt;Macros are Bad&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the search-expression within your OnOpen action worked it's ok. if not you could consider to simplify such search-expression with an additionally field MonthCounter, here an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/message/563904"&gt;Re: Howto make a variable to calculate quarters regarding year changes?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 09:30:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990665#M337555</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-11-13T09:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990666#M337556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Marcus for your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know macros are bad. but i need this post reload macro for default selections which works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Performance for on open triggers is bad. Hence&amp;nbsp; i wanna write few on open triggers in post relaod macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me on this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 09:49:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990666#M337556</guid>
      <dc:creator />
      <dc:date>2015-11-13T09:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990667#M337557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with Marcus. If you move to server reloading and hosting on a portal, neither OnPostReload or OnLoad will work, as the event triggers do not fire. Rather design your app using logic like this example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define a variable, for example in your load script):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Set vMax25 = '=Date(AddMonths(max(DATA_FIELD),-24))';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now use the variable in your set expressions like:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Sum({&amp;lt;Date = {"&amp;gt;=$(vMax25)"}&amp;gt;} Amount)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in the expression or chart label, you could use an expression like:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;='Amount since ' &amp;amp; vMax25&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The '=' sign in the variable definition means that the expression is calculated globally, and is updated as soon as the user makes a selection as the max(DATA_FIELD) will change as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:03:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990667#M337557</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2015-11-13T10:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990668#M337558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your specific case it is very helpful to make a calculated field called MonthsAgo which you can calculate from the DATA_FIELD like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(Today())*12 + Month(Today()) - Year(DATA_FIELD)*12 - Month(DATA_FIELD)&amp;nbsp; AS MonthsAgo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can make a static bookmark or a search that is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MonthsAgo&amp;lt;=24&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you should be able to do without a macro or trigger then... maybe...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:19:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990668#M337558</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-11-13T10:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990669#M337559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your macro would need to look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;var = Activedocument.Evaluate("&lt;/SPAN&gt;date(AddMonths(date#(max(DATA_FIELD),'YYYYMM'),-24),'YYYYMM')")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("DATA_FIELD").Select "&amp;gt;=" &amp;amp; var&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you have performance issues you should consider the suggestion from Jonathan and some more things, like a fewer open objects, using from calculation-conditions within the objects, using of a landing page ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:24:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990669#M337559</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-11-13T10:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro  to select latest 25 months</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990670#M337560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi khushboo, I would listen to Marcus and Jonathan and avoid macros if possible, anyway if you want the macro you can try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; vVar = Activedocument.Evaluate("date(AddMonths(date#(max(DATA_FIELD),'YYYYMM'),-24),'YYYYMM')")&lt;/P&gt;&lt;P&gt; ActiveDocument.Fields("DATA_FIELD").Select "&amp;lt;" + vVar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:25:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-select-latest-25-months/m-p/990670#M337560</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-11-13T10:25:31Z</dc:date>
    </item>
  </channel>
</rss>

