<?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 SET expression current month ok previous not ok in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118186#M633598</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;&lt;/P&gt;&lt;P&gt;I have below expression working fine for retuen current selected month amount :-&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({$&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;/P&gt;&lt;P&gt;year = {$(=max(year))}, &lt;/P&gt;&lt;P&gt;Month = {"&amp;lt;=$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month))&amp;gt;$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month)-1)"}&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&amp;nbsp; Amount/1000)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try to modify the above expression to below , in order to display previous month sales :-&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({$&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;/P&gt;&lt;P&gt;year = {$(=max(year))}, &lt;/P&gt;&lt;P&gt;Month = {"&amp;lt;=$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month))&amp;gt;$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month)-2)"}&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&amp;nbsp; Amount/1000)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it return null value. Can some one advise me where go wrong ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Jun 2016 19:43:27 GMT</pubDate>
    <dc:creator>paulyeo11</dc:creator>
    <dc:date>2016-06-02T19:43:27Z</dc:date>
    <item>
      <title>SET expression current month ok previous not ok</title>
      <link>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118186#M633598</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;&lt;/P&gt;&lt;P&gt;I have below expression working fine for retuen current selected month amount :-&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({$&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;/P&gt;&lt;P&gt;year = {$(=max(year))}, &lt;/P&gt;&lt;P&gt;Month = {"&amp;lt;=$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month))&amp;gt;$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month)-1)"}&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&amp;nbsp; Amount/1000)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try to modify the above expression to below , in order to display previous month sales :-&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({$&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;/P&gt;&lt;P&gt;year = {$(=max(year))}, &lt;/P&gt;&lt;P&gt;Month = {"&amp;lt;=$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month))&amp;gt;$(=max({&amp;lt;year={$(=max(year))}&amp;gt;} Month)-2)"}&lt;/P&gt;&lt;P&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;}&amp;nbsp;&amp;nbsp; Amount/1000)&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it return null value. Can some one advise me where go wrong ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:43:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118186#M633598</guid>
      <dc:creator>paulyeo11</dc:creator>
      <dc:date>2016-06-02T19:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: SET expression current month ok previous not ok</title>
      <link>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118187#M633599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;my QV Doc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 19:44:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118187#M633599</guid>
      <dc:creator>paulyeo11</dc:creator>
      <dc:date>2016-06-02T19:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: SET expression current month ok previous not ok</title>
      <link>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118188#M633600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could simplify those expressions by just using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Current Month:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14649042707355566" jivemacro_uid="_14649042707355566"&gt;&lt;STRONG&gt;Sum({$&amp;lt; year = {$(=max(year))}, month = {$(=Max(month))}&amp;gt;} Amount/1000)&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Past Month:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14649042765064143 jive_text_macro" jivemacro_uid="_14649042765064143"&gt;&lt;STRONG&gt;Sum({$&amp;lt; year = {$(=max(year))}, month = {$(=Max(month)-1)}&amp;gt;} Amount/1000)&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I would suggest create a variable for your previous Month to take into account January, something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;vPreviousMonth&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14649042914418082" jivemacro_uid="_14649042914418082"&gt;
&lt;P&gt;= If(Max(month) - 1 = 0, 12, month)&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And use it in your expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14649042868217944" jivemacro_uid="_14649042868217944"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Sum({$&amp;lt; year = {$(=max(year))}, month = {$(vPreviousMonth)}&amp;gt;} Amount/1000)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 21:52:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118188#M633600</guid>
      <dc:creator>alexdataiq</dc:creator>
      <dc:date>2016-06-02T21:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: SET expression current month ok previous not ok</title>
      <link>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118189#M633601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alejandro&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your advise. I notice that after you simplify the expression , now user must select current month and year. In fact i have make a lot of change to avoid select select month and year. So the same expression i can use in QS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2016 02:32:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SET-expression-current-month-ok-previous-not-ok/m-p/1118189#M633601</guid>
      <dc:creator>paulyeo11</dc:creator>
      <dc:date>2016-06-03T02:32:16Z</dc:date>
    </item>
  </channel>
</rss>

