<?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: Is there a way to load a script based on an if statement? in Qlik Automate</title>
    <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129482#M2578</link>
    <description>&lt;P&gt;Can't see a direct connection between your answer and the issue raised, but I would like to get more details, to understand.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2023 09:14:06 GMT</pubDate>
    <dc:creator>cotiso_hanganu</dc:creator>
    <dc:date>2023-10-18T09:14:06Z</dc:date>
    <item>
      <title>Is there a way to load a script based on an if statement?</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2128995#M2571</link>
      <description>&lt;DIV&gt;SAP1 ,SAP2, &lt;SPAN&gt;BASE1 &lt;/SPAN&gt;&lt;SPAN&gt;,BASE2 are all dates from another load table.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;I thought something like the below would work but it doesn't. Is there a way to create this type of logic?&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;IF (SAP1 &amp;gt;=&amp;nbsp; SAP2&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; AND BASE1 &amp;gt;= BASE2)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;THEN&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LOAD * FROM [lib://30_QVD_Extract/SAP1_BASE1.QVD] (qvd);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ELSEIF (SAP1 &amp;lt;&amp;nbsp; SAP2&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; AND BASE1 &amp;lt; BASE2)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;THEN&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LOAD * FROM [lib://30_QVD_Extract/SAP2_BASE2.QVD] (qvd);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ELSEIF (SAP1 &amp;gt;=&amp;nbsp; SAP2&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; AND BASE1 &amp;lt; BASE2)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;THEN&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LOAD * FROM [lib://30_QVD_Extract/SAP1_BASE2.QVD] (qvd);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;ELSEIF (SAP1 &amp;lt;&amp;nbsp; SAP2&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; AND BASE1 &amp;gt;= BASE2)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;THEN&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; LOAD * FROM [lib://30_QVD_Extract/SAP2_BASE1.QVD] (qvd);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;END IF;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 17 Oct 2023 00:18:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2128995#M2571</guid>
      <dc:creator>mgk123</dc:creator>
      <dc:date>2023-10-17T00:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to load a script based on an if statement?</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129052#M2572</link>
      <description>&lt;P&gt;Yes look at subroutines.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense/August2023/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Sub.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/August2023/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Sub.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Basically wrap each part of your script in a sub function, then build your if around the calls&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 06:40:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129052#M2572</guid>
      <dc:creator>Mark_Little</dc:creator>
      <dc:date>2023-10-17T06:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to load a script based on an if statement?</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129354#M2575</link>
      <description>&lt;P&gt;What would that look like with the query above?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 21:11:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129354#M2575</guid>
      <dc:creator>mgk123</dc:creator>
      <dc:date>2023-10-17T21:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to load a script based on an if statement?</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129476#M2577</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;First things first:&lt;BR /&gt;In order to use the content of a cell within a column within a table (matrix of values) in an if statement, you have to take it from the table into a variable (single value recipient).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;let vSAP1 = peek('SAP1',-1,'TableNameHavingSAP1');&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;... and so on ...&lt;STRONG&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;P&gt;1.In order to avoid confusion, it is a good practice to use a small &lt;STRONG&gt;v&lt;/STRONG&gt; at the beginning of the names of the variables.)&lt;/P&gt;
&lt;P&gt;2. I made an assumption that&amp;nbsp;&lt;EM&gt;TableNameHavingSAP1&amp;nbsp;&lt;/EM&gt;has only one row. I used &lt;STRONG&gt;-1&lt;/STRONG&gt; to get the LAST row . You can use &lt;STRONG&gt;0&lt;/STRONG&gt; to get the FIRST row (if you have only one row in the table, they are equivalent, but do not use &lt;STRONG&gt;1&lt;/STRONG&gt;, because it will look for the 2nd row, which might not exist , if you have only one row in the table)&lt;/P&gt;
&lt;P&gt;3. peek function requires single quotes for the names of Field and Table&lt;/P&gt;
&lt;P&gt;4. peek can be used in other cool ways&amp;nbsp; (even within inter record ops in load instructions)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And after that,&amp;nbsp; you can can really use the if statement...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;if vSAP1 &amp;gt;= vSAP2 and vBASE1 &amp;gt;= vBASE2 then &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; load whatever;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;else if&amp;nbsp;vSAP1 &amp;lt;= vSAP2 and vBASE1 &amp;gt;= vBASE2 then&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; load other;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;else&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; load 3rd option;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end if&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;P&gt;1. mandatory to have &lt;STRONG&gt;on a single ROW&lt;/STRONG&gt; the whole&amp;nbsp;&lt;STRONG&gt;if .... then&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;2. &lt;STRONG&gt;else if&lt;/STRONG&gt; can be used multiple times, of course. Or not at all.&lt;BR /&gt;&lt;STRONG&gt;else&lt;/STRONG&gt; only once at the end, or never.&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;you could also make the if statement directly:&lt;BR /&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;if peek('SAP1',-1,'TableNameHavingSAP1')&amp;gt;=peek('SAP2',-1,'TableNameHavingSAP2') then&lt;/STRONG&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;EM&gt;...&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;but it's harder to debug, in case you do not "peek" the right thing:&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck !&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 09:12:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129476#M2577</guid>
      <dc:creator>cotiso_hanganu</dc:creator>
      <dc:date>2023-10-18T09:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to load a script based on an if statement?</title>
      <link>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129482#M2578</link>
      <description>&lt;P&gt;Can't see a direct connection between your answer and the issue raised, but I would like to get more details, to understand.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 09:14:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-Automate/Is-there-a-way-to-load-a-script-based-on-an-if-statement/m-p/2129482#M2578</guid>
      <dc:creator>cotiso_hanganu</dc:creator>
      <dc:date>2023-10-18T09:14:06Z</dc:date>
    </item>
  </channel>
</rss>

