<?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 Variables and if statements in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variables-and-if-statements/m-p/520227#M1144245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've only just started using the software, so apologies if this should be simple, I'm looking for a bit of assistance...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a couple of expressions that are working fine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(if($(vShowQty)=1,QtyInvoiced,NetSalesValue))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$ &amp;lt;[Sales.Year]={"2010/11"}&amp;gt;} NetSalesValue)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable vShowQty is set based on two buttons and could either equal a 1 or 0.&amp;nbsp; Ideally, what I'm trying to do is combine the above two expressions into a single expression.&amp;nbsp; Essentially if vShowQty=1 and Sales.Year ="2010/11" I want to sum the QtyInvoiced, otherwise if vShowQty=0 and Sales.Year="2010/11" I would want to sum the NetSalesValue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if the above makes complete sense, but hopefully someone might be able to point me in the right direction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Aug 2013 16:35:33 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-08-22T16:35:33Z</dc:date>
    <item>
      <title>Variables and if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-and-if-statements/m-p/520227#M1144245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've only just started using the software, so apologies if this should be simple, I'm looking for a bit of assistance...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a couple of expressions that are working fine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(if($(vShowQty)=1,QtyInvoiced,NetSalesValue))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum({$ &amp;lt;[Sales.Year]={"2010/11"}&amp;gt;} NetSalesValue)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable vShowQty is set based on two buttons and could either equal a 1 or 0.&amp;nbsp; Ideally, what I'm trying to do is combine the above two expressions into a single expression.&amp;nbsp; Essentially if vShowQty=1 and Sales.Year ="2010/11" I want to sum the QtyInvoiced, otherwise if vShowQty=0 and Sales.Year="2010/11" I would want to sum the NetSalesValue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if the above makes complete sense, but hopefully someone might be able to point me in the right direction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 16:35:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-and-if-statements/m-p/520227#M1144245</guid>
      <dc:creator />
      <dc:date>2013-08-22T16:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Variables and if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-and-if-statements/m-p/520228#M1144246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if( vShowQty = 1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;sum({$ &amp;lt;[Sales.Year]={"2010/11"}&amp;gt;} QtyInvoiced),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum({$ &amp;lt;[Sales.Year]={"2010/11"}&amp;gt;} NetSalesValue)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since vShowQty is a variable you don't need to check it per record (i.e. inside the aggregation), and you probably don't need the dollar sign expansion $(..) when used in a chart expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;{$ &amp;lt;[Sales.Year]={"2010/11"}&amp;gt;} &lt;/SPAN&gt; is assigning value 2010/11 in a set expression's field selection, it's not really a condition as one can understand your above written requirement (if vShowQty=1 and Sales.Year = 2010/11 ...)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 17:08:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-and-if-statements/m-p/520228#M1144246</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-08-22T17:08:25Z</dc:date>
    </item>
  </channel>
</rss>

