<?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 Nested IF statement in the load script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216233#M69584</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to work for me...&lt;/P&gt;&lt;P&gt;The basic idea to to combine both tables into one to using the left join. If you want to keep both A &amp;amp; B seperate, only load the A fields (plus discounted price) in the RESIDENT Load. Then drop the temp table, next load Table B again. In the below example I am keeping both A &amp;amp; B as one table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps...&amp;gt;&lt;/P&gt;&lt;P&gt;tempTableA:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt; Products, OriginCountry, DestinationCountry, Price, Supplier, Createdate, Tax&lt;BR /&gt; A, UK, DE, 100, DEX, 2010-7-12, 16&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;LEFT JOIN (tempTableA)&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt; OriginCountryB, DestinationCountry, SupplierB, StartDate, EndDate, Promo&lt;BR /&gt; UK, DE, DEX, 2010-1-12, 2011-1-15, -9&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TableAB:&lt;BR /&gt;LOAD&lt;BR /&gt;Products&lt;BR /&gt;,OriginCountry&lt;BR /&gt;,DestinationCountry&lt;BR /&gt;,Price&lt;BR /&gt;,Supplier&lt;BR /&gt;,date#(date(Createdate,'MM-DD-YY')) as Createdate&lt;BR /&gt;,Tax&lt;BR /&gt;,OriginCountryB&lt;BR /&gt;//,DestinationCountry&lt;BR /&gt;,SupplierB&lt;BR /&gt;,date#(date(StartDate,'MM-DD-YY')) as StartDate&lt;BR /&gt;,date#(date(EndDate,'MM-DD-YY')) as EndDate&lt;BR /&gt;,Promo&lt;BR /&gt;//&lt;BR /&gt;// if product = A and OriginCountry = UK and DestinationCountry = DE and Supplier = DEX and Createdate is between table B StartDate &amp;amp; EndDate then apply 9% of promo on the price.&lt;BR /&gt;&lt;BR /&gt;,if(Products='A' And OriginCountry='UK' and DestinationCountry = 'DE' and Supplier = 'DEX' and Createdate &amp;gt;= StartDate and Createdate &amp;lt;= EndDate, Price + (Price * Promo / 100),Price) as DisountedPrice&lt;BR /&gt;&lt;BR /&gt;RESIDENT tempTableA&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;DROP TABLE tempTableA;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Dec 2010 19:43:42 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-12-08T19:43:42Z</dc:date>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216228#M69579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dea All,&lt;/P&gt;&lt;P&gt;I would like to create a new field in a table during the load script based on the following:&lt;/P&gt;&lt;P&gt;TableA&lt;/P&gt;&lt;P&gt;Products OriginCountry DestinationCountry Price Supplier Createdate Tax&lt;/P&gt;&lt;P&gt;A UK DE 100 DEX 07-12-2010 16&lt;/P&gt;&lt;P&gt;Table B&lt;/P&gt;&lt;P&gt;OriginCountry DestinationCountry Supplier Startdate EndDate Promo&lt;/P&gt;&lt;P&gt;UK DE DEX 01-12-2010 15-01-2011 -9&lt;/P&gt;&lt;P&gt;What I would like is to create a new field FinalPrice in Table A if :&lt;/P&gt;&lt;P&gt;if product = A and OriginCountry = UK and DestinationCountry = DE and Supplier = DEX and Createdate is between table B StartDate &amp;amp; EndDate then apply 9% of promo on the price.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;Guy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 19:36:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216228#M69579</guid>
      <dc:creator>guya</dc:creator>
      <dc:date>2010-12-07T19:36:17Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216229#M69580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which field do you use to join the two tables? Concatenation of Origin, Destination, and Supplier?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 20:19:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216229#M69580</guid>
      <dc:creator />
      <dc:date>2010-12-07T20:19:58Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216230#M69581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm usining the DestinationCountry.&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;Guy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 21:37:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216230#M69581</guid>
      <dc:creator>guya</dc:creator>
      <dc:date>2010-12-07T21:37:29Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216231#M69582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Guy ,&lt;/P&gt;&lt;P&gt;you can do the following&lt;/P&gt;&lt;P&gt;TableA&lt;/P&gt;&lt;P&gt;Products OriginCountry DestinationCountry Price Supplier Createdate Tax&lt;/P&gt;&lt;P&gt;A UK DE 100 DEX 07-12-2010 16&lt;/P&gt;&lt;P&gt;Join&lt;/P&gt;&lt;P&gt;OriginCountry DestinationCountry Supplier Startdate EndDate Promo&lt;/P&gt;&lt;P&gt;UK DE DEX 01-12-2010 15-01-2011 -9&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Price as PromoPrice ,&lt;/P&gt;&lt;P&gt;OriginCountry&lt;/P&gt;&lt;P&gt;resident Table1&lt;/P&gt;&lt;P&gt;where Product ='A' and OrginCountry='UK' and Destination Country ='DE' and Supplier ='DEX' and CreateDate &amp;gt;= StartDate and CreateDate &amp;lt;= EndDate .&lt;/P&gt;&lt;P&gt;Either you can join the table or be it as a seperate table ...&lt;/P&gt;&lt;P&gt;You can use the Promo Price and add the 9 % to it or you can do it using groupby funcion in the same table ..&lt;/P&gt;&lt;P&gt;Hope this helps you ...&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chakravarthy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 04:06:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216231#M69582</guid>
      <dc:creator />
      <dc:date>2010-12-08T04:06:04Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216232#M69583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;That doesn't help me to create an additional field in TableA or I miss something (I'm new in QV)&lt;/P&gt;&lt;P&gt;Also, the product is the reference for the conditions. So tI should get something like this:&lt;/P&gt;&lt;P&gt;If the product-OriginCountry= 'UK' and product-DestinationCountry= 'DE'....etc then Product-price * 0.09 and store it in FinalPrice.&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;Guy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 10:51:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216232#M69583</guid>
      <dc:creator>guya</dc:creator>
      <dc:date>2010-12-08T10:51:54Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216233#M69584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This seems to work for me...&lt;/P&gt;&lt;P&gt;The basic idea to to combine both tables into one to using the left join. If you want to keep both A &amp;amp; B seperate, only load the A fields (plus discounted price) in the RESIDENT Load. Then drop the temp table, next load Table B again. In the below example I am keeping both A &amp;amp; B as one table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps...&amp;gt;&lt;/P&gt;&lt;P&gt;tempTableA:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt; Products, OriginCountry, DestinationCountry, Price, Supplier, Createdate, Tax&lt;BR /&gt; A, UK, DE, 100, DEX, 2010-7-12, 16&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;LEFT JOIN (tempTableA)&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt; OriginCountryB, DestinationCountry, SupplierB, StartDate, EndDate, Promo&lt;BR /&gt; UK, DE, DEX, 2010-1-12, 2011-1-15, -9&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;TableAB:&lt;BR /&gt;LOAD&lt;BR /&gt;Products&lt;BR /&gt;,OriginCountry&lt;BR /&gt;,DestinationCountry&lt;BR /&gt;,Price&lt;BR /&gt;,Supplier&lt;BR /&gt;,date#(date(Createdate,'MM-DD-YY')) as Createdate&lt;BR /&gt;,Tax&lt;BR /&gt;,OriginCountryB&lt;BR /&gt;//,DestinationCountry&lt;BR /&gt;,SupplierB&lt;BR /&gt;,date#(date(StartDate,'MM-DD-YY')) as StartDate&lt;BR /&gt;,date#(date(EndDate,'MM-DD-YY')) as EndDate&lt;BR /&gt;,Promo&lt;BR /&gt;//&lt;BR /&gt;// if product = A and OriginCountry = UK and DestinationCountry = DE and Supplier = DEX and Createdate is between table B StartDate &amp;amp; EndDate then apply 9% of promo on the price.&lt;BR /&gt;&lt;BR /&gt;,if(Products='A' And OriginCountry='UK' and DestinationCountry = 'DE' and Supplier = 'DEX' and Createdate &amp;gt;= StartDate and Createdate &amp;lt;= EndDate, Price + (Price * Promo / 100),Price) as DisountedPrice&lt;BR /&gt;&lt;BR /&gt;RESIDENT tempTableA&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;DROP TABLE tempTableA;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 19:43:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216233#M69584</guid>
      <dc:creator />
      <dc:date>2010-12-08T19:43:42Z</dc:date>
    </item>
    <item>
      <title>Nested IF statement in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216234#M69585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its not a perfect solution but if Table B is "small" it should be descent. Could be that you need to add a trim inside the date#-functions.&lt;/P&gt;&lt;P&gt;temp:&lt;BR /&gt;noconcatenate load * resident TableA;&lt;BR /&gt;left join load * resident TableB;&lt;BR /&gt;&lt;BR /&gt;drop table TableA;&lt;BR /&gt;&lt;BR /&gt;TableA:&lt;BR /&gt;load Products,OriginCountry, DestinationCountry,Supplier,Createdate,Tax,Price&lt;BR /&gt;, if(date#(Startdate,'DD-MM-YYYY')&amp;lt;=date#(Createdate,'DD-MM-YYYY') and date#(Createdate,'DD-MM-YYYY')&amp;lt;=date#(EndDate,'DD-MM-YYYY'), Price * (100+Promo)/100,Price ) as FinalPrice&lt;BR /&gt;&lt;BR /&gt;resident temp;&lt;BR /&gt;drop table temp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 20:54:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-IF-statement-in-the-load-script/m-p/216234#M69585</guid>
      <dc:creator />
      <dc:date>2010-12-08T20:54:37Z</dc:date>
    </item>
  </channel>
</rss>

