<?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: set analysis, null values, if statement in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48030#M3269</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ciao Samuel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you could first create a table with Month,Year (Inline) and join a table with&amp;nbsp; Year,Month,&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;SalesYear to put this zero where you dont have Sales, after that use set analysis&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 May 2018 17:33:31 GMT</pubDate>
    <dc:creator>eduardo_dimperio</dc:creator>
    <dc:date>2018-05-17T17:33:31Z</dc:date>
    <item>
      <title>set analysis, null values, if statement</title>
      <link>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48029#M3268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to show in a straight table the sales amount for each month of the year (until the current one). Some months have no sales recorded, so I need a 0 output for them.&lt;BR /&gt;The sales amount is filtered by product (Product = 'OP').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the following set analysis but the result is not correct:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=SUM({&amp;lt;SalesYear = {$(vCurrentYear)}, YEAR = {$(#vYear)}, MONTH = {$(#vMonth)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product = {"OP"}&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; +&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SalesYear&amp;nbsp; = {$(vCurrentYear)}, YEAR = {$(#vYear)}, MONTH = {$(#vMonth)},&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product -= {"OP"}&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp; if(Product ='OP', Amount, 0) ) &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Note: YEAR and MONTH are used to show the data to a specific month of the year. If YEAR = 2018 and Month = '04' the report is updated at April, 30th.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I am using the if statement to choose whether or not to sum the 'Amount' field (is it possible/correct to do this?). But for some reason the amount returned for January is wrong (doubled, precisely).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I checked the Data Model and there are no no problems with it.&lt;BR /&gt;&lt;BR /&gt;Here's the table with the output.&lt;BR /&gt;&lt;BR /&gt;&lt;IMG alt="QS_wrong.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/202652_QS_wrong.PNG" style="height: auto;" /&gt;&lt;BR /&gt;&lt;BR /&gt;Here are the expected amounts (this shows that the Data Model is correctly designed):&lt;BR /&gt;&lt;IMG alt="QS_right.png" class="jive-image image-2" height="211" src="https://community.qlik.com/legacyfs/online/202657_QS_right.png" style="height: 211px; width: 769.529px;" width="770" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing is, I tried to sum 1 if Product = 'OP' (0 otherwise) and I get the right result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=SUM({&amp;lt;SalesYear = {$(vCurrentYear)}, YEAR = {$(#vYear)}, MONTH = {$(#vMonth)},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product = {"OP"}&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp; &amp;lt;SalesYear&amp;nbsp; = {$(vCurrentYear)}, YEAR = {$(#vYear)}, MONTH = {$(#vMonth)},&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product -= {"OP"}&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(Product ='OP', 1, 0) ) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 1 sales recorded in January and 4 sales recorded in March.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="qliksense_right2.PNG" class="jive-image image-3" height="157" src="https://community.qlik.com/legacyfs/online/202658_qliksense_right2.PNG" style="height: 156.771px; width: 402px;" width="402" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, what am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2018 10:51:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48029#M3268</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-17T10:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis, null values, if statement</title>
      <link>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48030#M3269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ciao Samuel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you could first create a table with Month,Year (Inline) and join a table with&amp;nbsp; Year,Month,&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;SalesYear to put this zero where you dont have Sales, after that use set analysis&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 May 2018 17:33:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48030#M3269</guid>
      <dc:creator>eduardo_dimperio</dc:creator>
      <dc:date>2018-05-17T17:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: set analysis, null values, if statement</title>
      <link>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48031#M3270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Eduardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I understood your answer, I think it wouldn't work as there are no rows having the product 'OP' in the fact table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My main question is: what's wrong with the set analysis I am using? I mean, is it correct to use the if statement like I did?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 May 2018 08:05:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/set-analysis-null-values-if-statement/m-p/48031#M3270</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-18T08:05:44Z</dc:date>
    </item>
  </channel>
</rss>

