<?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 Expressions Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284277#M496046</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello to all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am encountering a problem using a Set Expression. Here is what i want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to show the sum of my Net Sales over:&lt;/P&gt;&lt;P&gt;- Company Code 'NL'&lt;/P&gt;&lt;P&gt;- Year '2012'&lt;/P&gt;&lt;P&gt;- Intern/Extern: 'Extern'&lt;/P&gt;&lt;P&gt;- Period: previous period (Period = Month)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now as you can see, the first three are constants, and I had no trouble building them in, as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=sum({1 &amp;lt;CompanyCode={'NL'},[Intern/ Extern]={'Extern'},Year={'2012'}&amp;gt;}NetSales)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This one works: no matter what I select, the Net Sales shown is based on these 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, I want to add the last one. However, no matter what I try, I can't get it to work... &lt;/P&gt;&lt;P&gt;I tried adding a 'today' function, combining it with a 'mid' function, something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; white-space: pre; background-color: #ffffff;"&gt;=sum({1 &amp;lt;CompanyCode={'NL'},[Intern/ Extern]={'Extern'},Year={'2012'},&lt;STRONG&gt;Period={mid(today(0),5,1)}&lt;/STRONG&gt;&amp;gt;}NetSales)&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Today(0) gives '15/02/2012', so mid(5,1) gives '2'. However, it gives an error (Error in set modifier ad hoc element list:) and I can't get it right...&lt;/P&gt;&lt;P&gt;Anyone have any idea how I can automatically let QV show the data from the previous month?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Feb 2012 11:08:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-02-15T11:08:55Z</dc:date>
    <item>
      <title>Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284277#M496046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello to all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am encountering a problem using a Set Expression. Here is what i want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to show the sum of my Net Sales over:&lt;/P&gt;&lt;P&gt;- Company Code 'NL'&lt;/P&gt;&lt;P&gt;- Year '2012'&lt;/P&gt;&lt;P&gt;- Intern/Extern: 'Extern'&lt;/P&gt;&lt;P&gt;- Period: previous period (Period = Month)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now as you can see, the first three are constants, and I had no trouble building them in, as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=sum({1 &amp;lt;CompanyCode={'NL'},[Intern/ Extern]={'Extern'},Year={'2012'}&amp;gt;}NetSales)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This one works: no matter what I select, the Net Sales shown is based on these 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next, I want to add the last one. However, no matter what I try, I can't get it to work... &lt;/P&gt;&lt;P&gt;I tried adding a 'today' function, combining it with a 'mid' function, something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; white-space: pre; background-color: #ffffff;"&gt;=sum({1 &amp;lt;CompanyCode={'NL'},[Intern/ Extern]={'Extern'},Year={'2012'},&lt;STRONG&gt;Period={mid(today(0),5,1)}&lt;/STRONG&gt;&amp;gt;}NetSales)&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Today(0) gives '15/02/2012', so mid(5,1) gives '2'. However, it gives an error (Error in set modifier ad hoc element list:) and I can't get it right...&lt;/P&gt;&lt;P&gt;Anyone have any idea how I can automatically let QV show the data from the previous month?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:08:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284277#M496046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-15T11:08:55Z</dc:date>
    </item>
    <item>
      <title>Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284278#M496047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; create a variable to hold the value of mid(today(0),5,1)&lt;/P&gt;&lt;P&gt;Then use the variable in your set expression&amp;nbsp;&amp;nbsp; $(vMyVariable)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:12:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284278#M496047</guid>
      <dc:creator>m_woolf</dc:creator>
      <dc:date>2012-02-15T11:12:30Z</dc:date>
    </item>
    <item>
      <title>Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284279#M496048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; It is fine to use expression there, but the syntax is:&lt;BR /&gt;Period={"$(=&amp;lt;your expression&amp;gt;)"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the easier way to get month number from date is num(month(today()))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:32:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284279#M496048</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-15T11:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284280#M496049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further to mwoolf's solution, you can also just expand the mid(today(0),5,1) value making the second expression as this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({1 &amp;lt;CompanyCode={'NL'},},[Intern/ Extern]={'Extern'},Year={'2012'},Period={$(=mid(today(0),5,1))}&amp;gt;}NetSales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.. all depends on whether you prefer clearer expressions, or fewer variables!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flipside&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: Michael beat me to it!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: flipside&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:35:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284280#M496049</guid>
      <dc:creator>flipside</dc:creator>
      <dc:date>2012-02-15T11:35:42Z</dc:date>
    </item>
    <item>
      <title>Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284281#M496050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; You need do use withing dollar expansion $(=).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;CODE class="jive-code"&gt;=sum({1&amp;lt;CompanyCode={'NL'},[Intern/Extern]={'Extern'},Year={'2012'},Period={$(=mid(today(0),5,1))}&amp;gt;}NetSales)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Celambarasan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:37:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284281#M496050</guid>
      <dc:creator>CELAMBARASAN</dc:creator>
      <dc:date>2012-02-15T11:37:10Z</dc:date>
    </item>
    <item>
      <title>Set Expressions Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284282#M496051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, thank you all so much!&lt;/P&gt;&lt;P&gt;All of your solutions work perfectly, thank you all &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 11:46:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Expressions-Problem/m-p/284282#M496051</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-02-15T11:46:55Z</dc:date>
    </item>
  </channel>
</rss>

