<?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 Macro Problem: Selecting Previous Month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455806#M170160</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem in where i'm showing a Balanced Score Card on my dashboard. My employer asked me to select the previous month by default so that the tables show some values when the user views the dashboard. The only way conceivable of doing this, as I have found so far is to create a Macro function that runs on a trigger when OpenDocument occurs. I was able to get the current month and year by doing this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub DefaultLAFP2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v_monthyear = UCASE(Monthname(Month(now()),TRUE)) &amp;amp; " " &amp;amp; right(Year(now()),2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("MonthYear").Select v_monthyear&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The MonthYear field has values such as: JAN 13, FEB 13, MAR 13, etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I tried putting the -1 after the Month I was unable to get the desired result. I believe this is because QlikView doesn't let you subtract a month since in January it would crash. How can I achieve what I need? Help please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Feb 2013 16:56:26 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-02-20T16:56:26Z</dc:date>
    <item>
      <title>Macro Problem: Selecting Previous Month</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455806#M170160</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem in where i'm showing a Balanced Score Card on my dashboard. My employer asked me to select the previous month by default so that the tables show some values when the user views the dashboard. The only way conceivable of doing this, as I have found so far is to create a Macro function that runs on a trigger when OpenDocument occurs. I was able to get the current month and year by doing this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub DefaultLAFP2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v_monthyear = UCASE(Monthname(Month(now()),TRUE)) &amp;amp; " " &amp;amp; right(Year(now()),2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("MonthYear").Select v_monthyear&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The MonthYear field has values such as: JAN 13, FEB 13, MAR 13, etc...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I tried putting the -1 after the Month I was unable to get the desired result. I believe this is because QlikView doesn't let you subtract a month since in January it would crash. How can I achieve what I need? Help please.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 16:56:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455806#M170160</guid>
      <dc:creator />
      <dc:date>2013-02-20T16:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Problem: Selecting Previous Month</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455807#M170161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to use a macro. You can add a Select in Field action to the trigger instead. Choose MonthYear as field and try as search string =date(addmonths(today(),-1),'MMM YY').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 17:53:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455807#M170161</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-02-20T17:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Problem: Selecting Previous Month</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455808#M170162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That was the exact solution that I wanted. Thank you very much for your response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 18:03:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-Problem-Selecting-Previous-Month/m-p/455808#M170162</guid>
      <dc:creator />
      <dc:date>2013-02-20T18:03:41Z</dc:date>
    </item>
  </channel>
</rss>

