<?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: Using an IF statement in a variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296521#M822767</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe it's the if statement itself, try it with an OR instead of an AND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Oscar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Jul 2017 15:46:56 GMT</pubDate>
    <dc:creator>oscar_ortiz</dc:creator>
    <dc:date>2017-07-27T15:46:56Z</dc:date>
    <item>
      <title>Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296517#M822763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been trying to put the below expression into a variable so I can exclude all instances where the result is within 10%.&amp;nbsp; If the variable works I want to use is in set analysis in the following way; {&amp;lt;vVariance11%=1&amp;gt;} hence pulling out the records with a variance of over 10%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vVariance11%=if(([Under Distance]/[Original contract mileage])&amp;lt;=-0.1 and ([Under Distance]/[Original contract mileage])&amp;gt;= 0.1,0,1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I add this variable as a dimension in a straight table it always returns '1' and doesn't take into account the condition in the IF statement.&amp;nbsp; Can anyone point me in the right direction to make this work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296517#M822763</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296518#M822764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you share a sample with an expected output you are looking for? Would be easy to look into and work on.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jul 2017 16:29:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296518#M822764</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-07-26T16:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296519#M822765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may want to try adding that if statement to your script and creating a new [Variance Flag] column in your table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;If(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ([Under Distance]/[Original contract mileage]) &amp;lt;= -0.1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ([Under Distance]/[Original contract mileage]) &amp;gt;= 0.1,0,1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;) as [Variance Flag]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could easily use that in your set analysis statement. {&amp;lt; [Variance Flag] = {1} &amp;gt;}.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Oscar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jul 2017 19:59:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296519#M822765</guid>
      <dc:creator>oscar_ortiz</dc:creator>
      <dc:date>2017-07-26T19:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296520#M822766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Oscar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks for your suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried adding the IF statement to the load script as you suggest above (excluding the = in case that was causing problems), see below.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF(([Under Distance]/[Original contract mileage])&amp;lt;-0.1 and ([Under Distance]/[Original contract mileage])&amp;gt;0.1,0,1) as [Variance Flag],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;It still isn't applying the flag '0' to records falling within a 10% tolerance.&amp;nbsp; E.g. I have a variance of 0.07 and the '1' flag is being applied to it, along with every other record.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have added the following calculation into the load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Under Distance]/[Original contract mileage] as [Variance],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thinking was maybe I could use this derived field as part of the IF statement.&amp;nbsp; However, while I can use it as a dimension, it does not help me capture only records with a variance of +/- 10%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any other suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 15:16:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296520#M822766</guid>
      <dc:creator />
      <dc:date>2017-07-27T15:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296521#M822767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe it's the if statement itself, try it with an OR instead of an AND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Oscar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 15:46:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296521#M822767</guid>
      <dc:creator>oscar_ortiz</dc:creator>
      <dc:date>2017-07-27T15:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296522#M822768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've added an example document.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 16:05:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296522#M822768</guid>
      <dc:creator>oscar_ortiz</dc:creator>
      <dc:date>2017-07-27T16:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using an IF statement in a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296523#M822769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks Oscar.&amp;nbsp; That worked perfectly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 16:33:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-an-IF-statement-in-a-variable/m-p/1296523#M822769</guid>
      <dc:creator />
      <dc:date>2017-07-27T16:33:29Z</dc:date>
    </item>
  </channel>
</rss>

