<?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: Qlikview Multiple IF statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801524#M1211735</link>
    <description>&lt;P&gt;did you mean the Symbol should match but the BuySel_D shouldnt?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Apr 2021 20:24:37 GMT</pubDate>
    <dc:creator>edwin</dc:creator>
    <dc:date>2021-04-21T20:24:37Z</dc:date>
    <item>
      <title>Qlikview Multiple IF statement</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1800244#M1211606</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hoping someone can help me determine whether it is possible to implement the following logic in Qlik, or whether I need to change my dataset first before i load to Qlik.&amp;nbsp; The datasource is a csv file.&lt;/P&gt;&lt;P&gt;In the Straight Table I have the following (see screenshot):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Dimensions: date, Strategy, Contract (only one visible in screenshot but there are many), Symbol, Buy/Sell (please ignore this dimension), Commission&lt;/LI&gt;&lt;LI&gt;Expressions: Quantity, Gross Notional, P&amp;amp;L (commission * Gross Notional)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I need to somehow implement the following logic:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;IF MATCH "date" AND MATCH "Strategy" AND MATCH "Contract" but "Symbol" does NOT MATCH&lt;/LI&gt;&lt;LI&gt;Then "Commission" is divided by 2.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So for Person C and Person D, the commission figure would move from 0.04% to 0.02% on both lines.&lt;/P&gt;&lt;P&gt;For Person A there is added complication. If Quantity is not the same on both lines, then the commission rate should only be 0.025% for the lower quantity (1258 in this case). The difference of 74 (1258-1332) should be at 0.05%.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if this is achievable in Qlik but would really appreciate any guidance on how this could be achieved! Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Apr 2021 01:01:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1800244#M1211606</guid>
      <dc:creator>JM_Qlik</dc:creator>
      <dc:date>2021-04-17T01:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview Multiple IF statement</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801524#M1211735</link>
      <description>&lt;P&gt;did you mean the Symbol should match but the BuySel_D shouldnt?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 20:24:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801524#M1211735</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-04-21T20:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview Multiple IF statement</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801534#M1211737</link>
      <description>&lt;P&gt;Assuming sell is always negative and that you can aggregate in your script&lt;BR /&gt;and excluding commission and P&amp;amp;L as these are calculated, this the the starting numbers:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1619038831320.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53421i842E59E68B360746/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1619038831320.png" alt="edwin_0-1619038831320.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;you will need to get the minimum of the quantity when the totals are different, add rows for both buy and sell using the minimum magnitude of quantity then add new rows that hold the difference:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data:
load * inline [
Date, Strategy, Contract, Symbol, BuySell, Commision, Quantity
11/3/2021, Person A, KD, IX, Sell, .0005, -31
9/3/2021, Person A, KD, IX, Sell, .0005, -300
9/3/2021, Person A, KD, IX, Sell, .0005, -1000
9/3/2021, Person A, KD, IX, Sell, .0005, -32
9/3/2021, Person A, KD, IX, Buy, .0005, 1000
9/3/2021, Person A, KD, IX, Buy, .0005, 200
9/3/2021, Person A, KD, IX, Buy, .0005, 58
10/3/2021,Person A, KD, IX, Buy, .0005, 200
10/3/2021,Person A, KD, IX, Sell, .0005, -200
];


data2:
NoConcatenate
LOAD Date, Strategy, Contract, Symbol, Commision, sum(if(BuySell='Buy', (Quantity))) as BuyQuantity, sum(if(BuySell='Sell', (Quantity))) as SellQuantity
Resident data
group by Date, Strategy, Contract, Symbol, Commision;

drop table data;

data3:
load Date, Strategy, Contract, Symbol, Commision, 'Buy'as BuySell_D, 
if(fabs(SellQuantity)=fabs(BuyQuantity), 
	BuyQuantity,
	rangemin(fabs(SellQuantity),fabs(BuyQuantity))
) as Quantity
resident data2
where fabs(SellQuantity)=fabs(BuyQuantity) or rangemin(fabs(SellQuantity),fabs(BuyQuantity))&amp;gt;0
;

concatenate(data3)
load Date, Strategy, Contract, Symbol, Commision, 'Sell' as BuySell_D, 
if(fabs(SellQuantity)=fabs(BuyQuantity), 
	SellQuantity,
	-rangemin(fabs(SellQuantity),fabs(BuyQuantity))
) as Quantity
resident data2
where fabs(SellQuantity)=fabs(BuyQuantity) or rangemin(fabs(SellQuantity),fabs(BuyQuantity))&amp;gt;0
;


concatenate(data3)
load Date, Strategy, Contract, Symbol, Commision, 
if(fabs(SellQuantity)&amp;gt;fabs(BuyQuantity), 'Sell','Buy') as BuySell_D, 
SellQuantity + BuyQuantity as Quantity
resident data2
where fabs(SellQuantity)&amp;lt;&amp;gt;fabs(BuyQuantity) or rangemin(fabs(SellQuantity),fabs(BuyQuantity))=0
;
drop table data2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_1-1619039051468.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/53422i41713793D59275DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_1-1619039051468.png" alt="edwin_1-1619039051468.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;hope that helps&lt;/P&gt;</description>
      <pubDate>Wed, 21 Apr 2021 21:04:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801534#M1211737</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-04-21T21:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview Multiple IF statement</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801535#M1211738</link>
      <description>&lt;P&gt;you can also re-compute Commission, in the 1st 2 concatenate statement, use&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(fabs(sellQuantity)=fabs(buyQuantity), Commission/2, Commission) as Commission&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Apr 2021 21:07:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-Multiple-IF-statement/m-p/1801535#M1211738</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-04-21T21:07:46Z</dc:date>
    </item>
  </channel>
</rss>

