<?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 If statement in load script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30615#M606606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;I'm use an "if statement" to check a condition in load script, but I got this syntax error&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;this is the if statement: &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;IF count([Calendar year])= 0 THEN &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;DROP TABLE Data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Else &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Load data…&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;ENDIF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;The error I got is :&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Unexpected token: '=', expected: 'THEN'&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;IF (count([Calendar year])&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;=&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; 0) THEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;I also tried to put count([Calendar year])= 0 inside (), but still getting the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;any idea why?&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Thanks&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Yvonne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Mar 2018 21:04:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-03-14T21:04:31Z</dc:date>
    <item>
      <title>If statement in load script</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30615#M606606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;I'm use an "if statement" to check a condition in load script, but I got this syntax error&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;this is the if statement: &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;IF count([Calendar year])= 0 THEN &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;DROP TABLE Data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Else &lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Load data…&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;ENDIF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;The error I got is :&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Unexpected token: '=', expected: 'THEN'&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;IF (count([Calendar year])&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;=&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; 0) THEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;I also tried to put count([Calendar year])= 0 inside (), but still getting the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;any idea why?&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Thanks&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;&lt;/P&gt;&lt;P style="font-family: Arial; font-size: 10pt;"&gt;Yvonne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 21:04:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30615#M606606</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-14T21:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in load script</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30616#M606607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do something like below..&lt;/P&gt;&lt;P&gt;First load your original table... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Temp:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Load Count(Distinct Year) as TotalYear;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Load &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; FieldValue('Calendar year',RecNo()) as Year&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;AutoGenerate FieldValueCount('Calendar year');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Let vTotalYear = Peek('TotalYear',0,'Temp');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Drop Table Temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;IF vTotalYear = 0 THEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Drop Table Data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Load your data.....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 21:12:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30616#M606607</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2018-03-14T21:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in load script</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30617#M606608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Manish&lt;/P&gt;&lt;P&gt;Thanks for your code. I think it's working when&amp;nbsp; vTotalYear = 0 is tested true. However, it's possible that there's the field 'Calendar year' doesn't exist. and under that condition, it should go to else statement.. But the code is giving a field not found error. Any idea how to adjust the code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 21:27:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30617#M606608</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-14T21:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: If statement in load script</title>
      <link>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30618#M606609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change variable and assign vTotalYear to random value when Calendar Year field not exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vTotalYear = IF(Len(Trim(Peek('TotalYear',0,'Temp')))=0,100000,Peek('TotalYear',0,'Temp'));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2018 21:38:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-statement-in-load-script/m-p/30618#M606609</guid>
      <dc:creator>MK_QSL</dc:creator>
      <dc:date>2018-03-14T21:38:07Z</dc:date>
    </item>
  </channel>
</rss>

