<?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: Problem with If instruction in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450143#M1162287</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without knowing your data structure, I guess you should add some operation to MY_MARGIN field except it returns one value only. Otherwise you cannot divide an array of possible values by a unique SUM() of any other field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, try using the ONLY() function with just the field as parameter, keeping the "-1" outside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if the following expression works fine:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF (&lt;/EM&gt;&lt;EM&gt;SUM({&amp;lt;MY_YEAR={$(=ONLY(MY_ANNO)-1)}&amp;gt;} MY_SALES) = 0,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM(MY_MARGIN)/SUM({&amp;lt;MY_YEAR={$(=ONLY(MY_ANNO)-1)}&amp;gt;} MY_SALES)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Oct 2012 14:32:49 GMT</pubDate>
    <dc:creator>diegofcaivano</dc:creator>
    <dc:date>2012-10-25T14:32:49Z</dc:date>
    <item>
      <title>Problem with If instruction</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450141#M1162285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I'm becaming crazy. How don't understand where is my mistake&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13511079052436268" jivemacro_uid="_13511079052436268"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF (sum({&amp;lt;MY_YEAR={$(=Only(MY_ANNO-1))}&amp;gt;} MY_SALES) = 0,1, MY_MARGIN/sum({&amp;lt;MY_YEAR={$(=Only(MY_ANNO-1))}&amp;gt;} MY_SALES))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the script above, I would obtain the following scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if sum( ..... MY_SALES) = 0 , put MY_MARGIN = 1, else do the margin calculation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it doesn't work&lt;/P&gt;&lt;P&gt;Help please&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Oct 2012 19:50:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450141#M1162285</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-10-24T19:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If instruction</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450142#M1162286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't see anything wrong with it. If you select a value for MY_ANNO then you should get a result as long as there is data where MY_YEAR = MY_ANNO - 1 &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 14:19:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450142#M1162286</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2012-10-25T14:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with If instruction</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450143#M1162287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without knowing your data structure, I guess you should add some operation to MY_MARGIN field except it returns one value only. Otherwise you cannot divide an array of possible values by a unique SUM() of any other field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, try using the ONLY() function with just the field as parameter, keeping the "-1" outside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if the following expression works fine:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IF (&lt;/EM&gt;&lt;EM&gt;SUM({&amp;lt;MY_YEAR={$(=ONLY(MY_ANNO)-1)}&amp;gt;} MY_SALES) = 0,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM(MY_MARGIN)/SUM({&amp;lt;MY_YEAR={$(=ONLY(MY_ANNO)-1)}&amp;gt;} MY_SALES)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 14:32:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-If-instruction/m-p/450143#M1162287</guid>
      <dc:creator>diegofcaivano</dc:creator>
      <dc:date>2012-10-25T14:32:49Z</dc:date>
    </item>
  </channel>
</rss>

