<?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: Incorporating if statements within variable expressions in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471474#M486329</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can test the if condition using a text box first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i text box&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try: &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;if (&lt;STRONG&gt;$(vStartYear)&lt;/STRONG&gt;&amp;lt; 2012&lt;/STRONG&gt;,'YES','No')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if yes prints on text box that means the condition is working and then use the formula:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;if (&lt;STRONG&gt;$(vStartYear)&lt;/STRONG&gt;&amp;lt; 2012, &lt;STRONG&gt;Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales) &lt;/STRONG&gt;/ 1.3,&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;HTH&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;Sushil&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 23 Mar 2013 05:43:01 GMT</pubDate>
    <dc:creator>sushil353</dc:creator>
    <dc:date>2013-03-23T05:43:01Z</dc:date>
    <item>
      <title>Incorporating if statements within variable expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471471#M486326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My data source has three columns:&amp;nbsp; Year, Country, Sales $ (sales dollars by different countries from 2008-2012).&amp;nbsp; In QV I created two variables called "Start Year" and "End Year".&amp;nbsp; I then created an input box with with these two variables.&amp;nbsp; From an end-user perspective, the user enters a "start year" (2010 for example) and an "end year" (2012 for example).&amp;nbsp; The results are displayed in a straight table, where sales $ are shown by country in "start year" and "end year" columns.&amp;nbsp; The expressions used to display are below: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}(Sales))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum({$&amp;lt;Year ={$(vEndYear)}&amp;gt;}(Sales))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to incorporate logic that says "if the year entered is less than 2012, divide sales by 1.3" (for either start or end year).&amp;nbsp; How do I do this?&amp;nbsp; I have other bar charts where I use the expression &lt;STRONG&gt;if (Year &amp;lt; 2012, (Sum (Sales)/1.3),(Sum (Sales)) &lt;/STRONG&gt;successfully&lt;STRONG style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;.&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;(before anyone suggest that I just divide the sales totals by 1.3 in the source data, I'm simply using 1.3 as a proxy for this example.&amp;nbsp; In my actual QV solution, the "1.3" is a variable that can be changed by the user)&lt;/SPAN&gt;&lt;STRONG style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Mar 2013 02:45:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471471#M486326</guid>
      <dc:creator />
      <dc:date>2013-03-23T02:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Incorporating if statements within variable expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471472#M486327</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;Expr1:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;if (&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;$(vStartYear)&lt;/STRONG&gt;&amp;lt; 2012, &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales) &lt;/STRONG&gt;/ $(vFactor),&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt; &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;/STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expr2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;if (&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;$(&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vEndYear&lt;/STRONG&gt;&lt;/STRONG&gt;)&lt;/STRONG&gt;&amp;lt; 2012, &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;Sum({$&amp;lt;Year ={$(&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vEndYear&lt;/STRONG&gt;&lt;/STRONG&gt;)}&amp;gt;}Sales) &lt;/STRONG&gt;/ $(vFactor),&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum({$&amp;lt;Year ={$(&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vEndYear&lt;/STRONG&gt;&lt;/STRONG&gt;)}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;/STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vFactor&lt;/STRONG&gt; = If(&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vStartYear&lt;/STRONG&gt;&lt;/STRONG&gt; &amp;lt; 2012 or &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;vEndYear&lt;/STRONG&gt; &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&amp;lt; 2012&lt;/STRONG&gt;, 1.3, 1)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;Regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;som&lt;/STRONG&gt;&lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Mar 2013 04:16:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471472#M486327</guid>
      <dc:creator>somenathroy</dc:creator>
      <dc:date>2013-03-23T04:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Incorporating if statements within variable expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471473#M486328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;You can evaluate the expression using date from which you have evaluate your year ,start year,end year...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if($(vEndYear)&amp;lt;=31-12-2012,sum({$&amp;lt;date={"&amp;gt;=$(vStartYear)&amp;lt;=$(vEndYear))"}&amp;gt;}Sales)/$(vinput),sum({$&amp;lt;date={"&amp;gt;=$(vStartYear)&amp;lt;=$(vEndYear))"}&amp;gt;}Sales))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here vinput is the variable to divide total as per user input when year is less than 2012.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Udit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Mar 2013 04:31:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471473#M486328</guid>
      <dc:creator>udit_kumar_sana</dc:creator>
      <dc:date>2013-03-23T04:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Incorporating if statements within variable expressions</title>
      <link>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471474#M486329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can test the if condition using a text box first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i text box&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try: &lt;STRONG style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;if (&lt;STRONG&gt;$(vStartYear)&lt;/STRONG&gt;&amp;lt; 2012&lt;/STRONG&gt;,'YES','No')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if yes prints on text box that means the condition is working and then use the formula:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;if (&lt;STRONG&gt;$(vStartYear)&lt;/STRONG&gt;&amp;lt; 2012, &lt;STRONG&gt;Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales) &lt;/STRONG&gt;/ 1.3,&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sum({$&amp;lt;Year ={$(vStartYear)}&amp;gt;}Sales)&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;HTH&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;Sushil&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Mar 2013 05:43:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Incorporating-if-statements-within-variable-expressions/m-p/471474#M486329</guid>
      <dc:creator>sushil353</dc:creator>
      <dc:date>2013-03-23T05:43:01Z</dc:date>
    </item>
  </channel>
</rss>

