<?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 How to write an If logic in Load Script with multiple conditions in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1971838#M1220582</link>
    <description>&lt;P data-unlink="true"&gt;Hi&amp;nbsp;Experts,&lt;/P&gt;
&lt;P&gt;I've the below example data.&lt;/P&gt;
&lt;TABLE border="1" width="25%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;candidate&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Sales&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;700&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;900&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;&lt;SPAN&gt;Test1&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD height="25px"&gt;2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;&lt;SPAN&gt;Test2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD height="25px"&gt;3000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected Output&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;candidate&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Sales&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;3,300 (100+200+400+500+600+700+800)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;3,800 (100+300+400+500+600+900+1000)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;SPAN&gt;Test1&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;SPAN&gt;Test2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;3000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here we are adding&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;Exec-123&lt;/STRONG&gt; values to&amp;nbsp;&lt;STRONG&gt;Exec1-567&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;Exec1-890&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I've the below two set analysis created for it but I would like to it in load script.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;=sum({&amp;lt;candidate={"*Exec*"}&amp;gt;}Sales)+sum({&amp;lt;candidate={"*Exec1*"}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;=sum({&amp;lt;candidate={"*Exec2*"}&amp;gt;}Sales)+sum({&amp;lt;candidate={"*Exec1*"}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As a work around I did it by taking the resident load of the main table. But is there any if statement I can use directly in the main table rather than taking residents and calculating&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Barat Vikas&lt;/P&gt;</description>
    <pubDate>Tue, 23 Aug 2022 10:12:57 GMT</pubDate>
    <dc:creator>vikasshana</dc:creator>
    <dc:date>2022-08-23T10:12:57Z</dc:date>
    <item>
      <title>How to write an If logic in Load Script with multiple conditions</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1971838#M1220582</link>
      <description>&lt;P data-unlink="true"&gt;Hi&amp;nbsp;Experts,&lt;/P&gt;
&lt;P&gt;I've the below example data.&lt;/P&gt;
&lt;TABLE border="1" width="25%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;candidate&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Sales&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;300&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;400&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;500&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Exec-123&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;700&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;800&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;900&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec2-890&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;1000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;&lt;SPAN&gt;Test1&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD height="25px"&gt;2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;&lt;SPAN&gt;Test2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD height="25px"&gt;3000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expected Output&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;candidate&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="25px"&gt;&lt;SPAN&gt;Sales&lt;/SPAN&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-567&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;3,300 (100+200+400+500+600+700+800)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%" height="47px"&gt;&lt;SPAN&gt;Exec1-890&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD width="12.5%" height="47px"&gt;3,800 (100+300+400+500+600+900+1000)&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;SPAN&gt;Test1&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;SPAN&gt;Test2&lt;/SPAN&gt;&lt;/TD&gt;
&lt;TD&gt;3000&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here we are adding&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;Exec-123&lt;/STRONG&gt; values to&amp;nbsp;&lt;STRONG&gt;Exec1-567&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;Exec1-890&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I've the below two set analysis created for it but I would like to it in load script.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;=sum({&amp;lt;candidate={"*Exec*"}&amp;gt;}Sales)+sum({&amp;lt;candidate={"*Exec1*"}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;=sum({&amp;lt;candidate={"*Exec2*"}&amp;gt;}Sales)+sum({&amp;lt;candidate={"*Exec1*"}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;As a work around I did it by taking the resident load of the main table. But is there any if statement I can use directly in the main table rather than taking residents and calculating&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Barat Vikas&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 10:12:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1971838#M1220582</guid>
      <dc:creator>vikasshana</dc:creator>
      <dc:date>2022-08-23T10:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an If logic in Load Script with multiple conditions</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1972391#M1220593</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/3349"&gt;@vikasshana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can use this version in load script:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;Data:

LOAD *,if(candidate='Exec-123' or candidate='Exec1-567','Exec1-567',candidate) as candidate1
,if(candidate='Exec-123' or candidate='Exec2-890','Exec2-890',candidate) as candidate2 INLINE [
    candidate , Sales
    Exec-123 , 100
    Exec1-567 , 200
    Exec2-890 , 300
    Exec-123 , 400 
    Exec-123 , 500
    Exec-123 , 600
    Exec1-567 , 700
    Exec1-567 , 800
    Exec2-890 , 900
    Exec2-890 , 1000
    Test1 , 2000
    Test2 , 3000
];

output:

load candidate1 as candidate,sum(Sales) as Sales resident Data where candidate1='Exec1-567' group by candidate1 ;
load candidate2 as candidate,sum(Sales) as Sales resident Data where candidate2='Exec2-890' group by candidate2 ;
load candidate as candidate,sum(Sales) as Sales resident Data where Match(candidate,'Exec2-890','Exec1-567','Exec-123')=0 group by candidate ;
drop table Data;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output:&lt;/P&gt;
&lt;P&gt;dimension candidate and measure sum(Sales):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Taoufiq_Zarra_0-1661333176751.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87402i781889F4D4B144E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Taoufiq_Zarra_0-1661333176751.png" alt="Taoufiq_Zarra_0-1661333176751.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 09:26:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1972391#M1220593</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2022-08-24T09:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an If logic in Load Script with multiple conditions</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1976769#M1220814</link>
      <description>&lt;P&gt;You're essentially including specific fact rows in two different calculations. If you do this on the script side like &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/56648"&gt;@Taoufiq_Zarra&lt;/a&gt; solution suggests, you have to duplicate your fact rows, which is generally ill-advised, as your fact data is now not sum-able without de-duplication logic which adds generally unnecessary complexity to the frontend.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2022 06:45:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-write-an-If-logic-in-Load-Script-with-multiple-conditions/m-p/1976769#M1220814</guid>
      <dc:creator>oskartoivonen</dc:creator>
      <dc:date>2022-09-05T06:45:46Z</dc:date>
    </item>
  </channel>
</rss>

