<?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: Nested If Condition issue in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488488#M182533</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It certainly helps.&lt;/P&gt;&lt;P&gt;I had to use OR there...&lt;/P&gt;&lt;P&gt;I am going to use your last suggestion to have a AmountFinal column. It makes perfect sense.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Nov 2013 19:45:13 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-11-06T19:45:13Z</dc:date>
    <item>
      <title>Nested If Condition issue</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488486#M182531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I have a nested If condition statement which is not working as expected...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sum (if (Transactions.TxnType='Estimate' and Transactions.TxnType='Sales Order',0,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( (ClassifiedAccountType = 'Income'&amp;nbsp; or ClassifiedAccountType = 'Liability' or ClassifiedAccountType = 'Equity') and Transactions.DebitOrCredit = 'Credit',Transactions.Amount,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( (ClassifiedAccountType = 'Assest' or ClassifiedAccountType = 'Expense') and Transactions.DebitOrCredit = 'Debit', Transactions.Amount,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( (ClassifiedAccountType = 'Income' or ClassifiedAccountType = 'Liability' or ClassifiedAccountType = 'Equity') and Transactions.DebitOrCredit = 'Debit',-Transactions.Amount,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if((ClassifiedAccountType = 'Assest' or ClassifiedAccountType = 'Expense') and Transactions.DebitOrCredit = 'Credit', -Transactions.Amount))))))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it suppose to work like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if ((Transactions.TxnType='Estimate' and Transactions.TxnType='Sales Order) Then &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Amount = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else if ((ClassifiedAccountType = 'Income'&amp;nbsp; or ClassifiedAccountType = 'Liability' or ClassifiedAccountType = 'Equity') and Transactions.DebitOrCredit = 'Credit',) Then&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Amount = Transactions.Amount&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else&amp;nbsp; if( (ClassifiedAccountType = 'Assest' or ClassifiedAccountType = 'Expense') and Transactions.DebitOrCredit = 'Debit') Then&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Amount = Transactions.Amount&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and so forth...&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is with the first If condition...&lt;/P&gt;&lt;P&gt;it is not making Amount = 0 when the TxnType is Estimate or Sales Order instead it is taking the second "If" because ClassifiedAccountType for Estimate and Sales Order is Income and Transactions.DebitOrCredit is Credit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assumed that once it has gone under first if condition then it will not under another "If" condition" So I kept it as first condition to exclude Estimate and Sales Order before i check ClassifiedAccountTypes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to fix it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Saurabh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 19:15:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488486#M182531</guid>
      <dc:creator />
      <dc:date>2013-11-06T19:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Nested If Condition issue</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488487#M182532</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;Would your first line contain a typing error, you're using "and" instead of "or":&lt;/P&gt;&lt;P&gt;TxnType = 'Estimate' AND TxnType = 'Sales Order' =&amp;gt; this should be OR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is just a typing error here and not in your app, then I'd suggest you use set analysis instead of nested if which can be resource consuming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another solution would be, if your conditions are a set of business rules that won't change, to create a field in your script, say AmountFinal, which will be filled with the amount that will be displayed; you'll use there your nested if as the definition of this field and then your expression would simply be sum(AmountFinal), for example:&lt;/P&gt;&lt;P&gt;Load TxnType,&lt;/P&gt;&lt;P&gt;ClassifiedAccountType,&lt;/P&gt;&lt;P&gt;DebitOrCredit,&lt;/P&gt;&lt;P&gt;if(Match(TxnType, 'Estimate', 'Sales Order'), 0, if(Match(ClassifiedAccountType, 'Income', 'Liability')... etc. ) as AmountFinal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 19:40:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488487#M182532</guid>
      <dc:creator />
      <dc:date>2013-11-06T19:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Nested If Condition issue</title>
      <link>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488488#M182533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It certainly helps.&lt;/P&gt;&lt;P&gt;I had to use OR there...&lt;/P&gt;&lt;P&gt;I am going to use your last suggestion to have a AmountFinal column. It makes perfect sense.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 19:45:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Nested-If-Condition-issue/m-p/488488#M182533</guid>
      <dc:creator />
      <dc:date>2013-11-06T19:45:13Z</dc:date>
    </item>
  </channel>
</rss>

