<?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: switch case - If...else problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606438#M682403</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try with this script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let _vAction=1;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SWITCH $(_vAction)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CASE 1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileName = 'xxxx';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileNameD = '$(_vFileName)'&amp;amp;'.qvd';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileExists = if(FileSize('$(_vFileNameD)') &amp;gt; 0, -1, 0);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; SWITCH $(_vFileExists) &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; CASE 0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText1='stops here';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; CASE&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText1='why stop here??';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; ENDSWITCH&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CASE 2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText='Case 2';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; let _vText1='win!!';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ENDSWITCH&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Mar 2014 22:43:19 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-03-05T22:43:19Z</dc:date>
    <item>
      <title>switch case - If...else problem</title>
      <link>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606437#M682401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;attached its an example of my problem....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why its stopping in the else inside case 1??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 21:55:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606437#M682401</guid>
      <dc:creator />
      <dc:date>2014-03-05T21:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: switch case - If...else problem</title>
      <link>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606438#M682403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try with this script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let _vAction=1;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SWITCH $(_vAction)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CASE 1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileName = 'xxxx';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileNameD = '$(_vFileName)'&amp;amp;'.qvd';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vFileExists = if(FileSize('$(_vFileNameD)') &amp;gt; 0, -1, 0);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; SWITCH $(_vFileExists) &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; CASE 0&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText1='stops here';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; CASE&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText1='why stop here??';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; ENDSWITCH&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CASE 2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; LET _vText='Case 2';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; let _vText1='win!!';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ENDSWITCH&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 22:43:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606438#M682403</guid>
      <dc:creator />
      <dc:date>2014-03-05T22:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: switch case - If...else problem</title>
      <link>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606439#M682404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;replace&lt;/P&gt;&lt;P&gt;IF $(_vFileExists)=0 THEN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with&lt;/P&gt;&lt;P&gt;IF ($(_vFileExists)=0) THEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 23:07:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606439#M682404</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-03-05T23:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: switch case - If...else problem</title>
      <link>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606440#M682405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's a little bit of an oddity as to how the script interpretation and execution flows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are triggering Case 2. The statements in Case 1 do not get executed, but they do get expanded and syntax checked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable _vFileExists never get intialized (the LET doesn't get executed) so the IF statement that references it gets expanded to:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;"IF =0 THEN"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;which is invalid (not trapped until the ELSE).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can fix the problem by initializing the variable before the SWITCH.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LET _vFileExists = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or code the IF statement to tolerate an empty variable by including quotes.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;IF &lt;STRONG&gt;'&lt;/STRONG&gt;$(_vFileExists)&lt;STRONG&gt;'&lt;/STRONG&gt;=0 THEN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com/"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 23:41:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/switch-case-If-else-problem/m-p/606440#M682405</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2014-03-05T23:41:39Z</dc:date>
    </item>
  </channel>
</rss>

