<?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: IF Statement for positive and negative values in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152194#M906850</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using Sign(&lt;SPAN style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Sum ([Gross Profit])) * your expression&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jun 2016 12:15:13 GMT</pubDate>
    <dc:creator>Clever_Anjos</dc:creator>
    <dc:date>2016-06-20T12:15:13Z</dc:date>
    <item>
      <title>IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152192#M906848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm new to Qlik and have hit an issue when calculating my Gross Margin for a product, which hopefully will be an easy answer &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/laugh.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an item which I have credited for £39, meaning my sales revenue is £-39, my Gross Profit on this item is therefore -£14.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am then calculating my GM as (Sum ([Gross Profit]) / (Sum ([Sales Revenue]), however this produces a positive value of 36.8%, which should actually be a negative. I've structured the data going into the .qvd as a negative on GP if the SR is negative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I'm actually trying to achieve is this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the sum of Gross Profit/Sales Revenue is a negative, then produce a negative GM, else If the sym of Gross Profit/Sales Revenue is a positive then produce a positive GM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152192#M906848</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152193#M906849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, just to confirm - My data is being loaded from a .qvd as a negative - I want to add this calculation as a variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 11:10:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152193#M906849</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-20T11:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152194#M906850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using Sign(&lt;SPAN style="color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Sum ([Gross Profit])) * your expression&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:15:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152194#M906850</guid>
      <dc:creator>Clever_Anjos</dc:creator>
      <dc:date>2016-06-20T12:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152195#M906851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Use Fabs on denominator:&lt;/P&gt;&lt;P&gt;Sum([Gross Profit])/Fabs(Sum([Sales Revenue]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As your Gross Profit is negative, your result will be negative.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:18:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152195#M906851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-20T12:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152196#M906852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&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;&amp;nbsp; This is an arithmetic query rather than QV. The GM calculation of +36.8% is correct, I wouldn't change it. Bear in mind that it is a percentage of a negative amount -£39 so the calculation +36.8% of -£39 gives the correct profit of approx -£14.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you massage the % to show it as a -ve value this would be misleading. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whether you make a sales or a credit refund you need to keep the profit calculation consistent or else when you aggregate over a number of transactions you will get false results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:22:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152196#M906852</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2016-06-20T12:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152197#M906853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the replies, this is the current setup for the calculation, which produces the margin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As suggested by Andrew, I need to be selective - So, if Total Sales &amp;lt;0 then Total Gross Profit, else If Total Sales =&amp;gt;0 then TGP/TS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/128510_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:25:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152197#M906853</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-20T12:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152198#M906854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David, &lt;/P&gt;&lt;P&gt;i don't understand your issue, if you divide two negative numbers it will always return a positive result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;(Sum ([Gross Profit])= -14&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;(Sum ([Sales Revenue])= -39&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;(Sum ([Gross Profit]) / (Sum ([Sales Revenue])= 0.358 = 35.8%&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please elaborate more or share a sample app in order to help you with your issue.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:28:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152198#M906854</guid>
      <dc:creator>santiago_respane</dc:creator>
      <dc:date>2016-06-20T12:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152199#M906855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santiago,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i'm attempting to do is check if both the numbers are a negative, and if so produce a negative value, if they aren't, then produce a positive value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:51:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152199#M906855</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-20T12:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152200#M906856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;you can try something like this:&lt;/P&gt;&lt;P&gt;=IF(Column(1)&amp;lt;0 and Column(2)&amp;lt;0,(Column(1)/Column(2))*-1,(Column(1)/Column(2)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if this helps.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 13:00:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152200#M906856</guid>
      <dc:creator>santiago_respane</dc:creator>
      <dc:date>2016-06-20T13:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF Statement for positive and negative values</title>
      <link>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152201#M906857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, this is what I was after! Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 13:12:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-Statement-for-positive-and-negative-values/m-p/1152201#M906857</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-20T13:12:05Z</dc:date>
    </item>
  </channel>
</rss>

