<?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: If Condition is not working as expected in script or expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759608#M453969</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This could be a total red herring, but noting you have a space at the start of [ Net Price], is that actually in your fields or an issue when copying over? Do you get an error in the UI when you see '-' in text box?&lt;/P&gt;&lt;P&gt;I think in the original post you mentioned using in the load script - if you did not have appropriate grouping you would get Invalid Expression error, that might be worth investigating.&lt;/P&gt;&lt;P&gt;From experience I think you may also need to look at the order you sum in, depending how you aggregate, so if Discount were a percentage say I think I would expect to see Sum([Net Price]*[Discount]) rather than&amp;nbsp;Sum([Net Price])*Sum([Discount]) ... but there may be some quirks in your data model that are not obvious.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Chris.&lt;/P&gt;</description>
    <pubDate>Sun, 08 Nov 2020 14:11:12 GMT</pubDate>
    <dc:creator>chrismarlow</dc:creator>
    <dc:date>2020-11-08T14:11:12Z</dc:date>
    <item>
      <title>If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759241#M453944</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;Very strange, simple If condition is not working as expected. Whenever I used in the text box, it shows null and in the script, It's throwing the error as invalid expression. Can anyone suggest me why it behaves like this?&lt;/P&gt;&lt;P&gt;If condition&amp;nbsp; I am loading at load statement in the script by taking resident.&lt;/P&gt;&lt;P&gt;IF([Type]='Champion',0,IF(Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity])),(Sum([ Net Price])*Sum([Discount])))) as Test&lt;/P&gt;&lt;P&gt;The expected output is, Type=Champion is not there in my current data, It should goes to else part to Second If condition.&lt;/P&gt;&lt;P&gt;Sum(Sales) =1158 and Sum(LP)* Sum(Quantity) =1158 so, I need Sum(Net Price)* Sum(Discount) amount.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:40:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759241#M453944</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2024-11-15T23:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759247#M453945</link>
      <description>&lt;P&gt;Hi, You have include Else part for both fail cases like&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;IF([Type]='Champion',0,IF(Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity])),(Sum([ Net Price])*Sum([Discount]))&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;,&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;(Sum([ Net Price])*Sum([Discount]))&lt;/FONT&gt;&lt;/STRONG&gt;)) as Test&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 10:16:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759247#M453945</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-11-06T10:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759253#M453946</link>
      <description>&lt;P&gt;Hi Anil,&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;I cannot do that because, I am having another condition for else. The if condition is failing at stage 2 itself.&lt;/P&gt;&lt;P&gt;My Actual expression is&lt;/P&gt;&lt;P&gt;If([ Type]='Champion',0,&lt;BR /&gt;if(Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity])),(Sum([ Net Price])*Sum([Discount]))&lt;BR /&gt;, (Sum([Sales])-(Sum([Promo LP])*Sum([Quantity])))/(Sum([Sales])*Sum([Net Price]))))&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 10:30:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759253#M453946</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-06T10:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759277#M453948</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/44466"&gt;@krishna20&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need aggregation functions ( as sum, count etc) loading from a table (resident via in your case), you need to use group by clause to tell Qlik for wich dimension you want calculate.&lt;/P&gt;&lt;P&gt;That's why you are receiving such "invalid expression" script error.&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 11:10:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759277#M453948</guid>
      <dc:creator>forte</dc:creator>
      <dc:date>2020-11-06T11:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759299#M453949</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;Yes, I notified that. Thanks for reminding me again. But , I am mainly focusing on writing the expression on front end in the chart.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 12:16:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759299#M453949</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-06T12:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759321#M453951</link>
      <description>&lt;P&gt;If that is the case, How come it is multiplying with LP?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Sum([LP])*Sum([Quantity]))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I believe, There is no script error during reload. If so, try this?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF(Sum([Sales])&amp;lt;=Sum([Quantity]),(Sum([ Net Price])*Sum([Discount]), 'Else Condition If needed')&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 13:13:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759321#M453951</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-11-06T13:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759393#M453958</link>
      <description>&lt;P&gt;Hi Anil,&lt;/P&gt;&lt;P&gt;It is my requirement and condition should satisfies with&amp;nbsp;&lt;SPAN&gt;Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity]). We cannot ignore Sum(LP)*Sum(Quantity).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 16:08:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759393#M453958</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-06T16:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759436#M453959</link>
      <description>&lt;P&gt;The reason I asked because of your explanation (In that there is nothing LP)&lt;/P&gt;&lt;P&gt;Anyway, What are you getting using this&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IF(Sum([Sales])&amp;lt;=(&lt;SPAN&gt;Sum(LP)*&lt;/SPAN&gt;Sum([Quantity])),(Sum([ Net Price])*Sum([Discount]), 'Else Condition If needed')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Can you please demonstrate the similar issue in sample applicaiton which may help quicker.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 18:25:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759436#M453959</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-11-06T18:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759595#M453966</link>
      <description>&lt;P&gt;Hi Anil,&lt;/P&gt;&lt;P&gt;Unable to share sample app due to data privacy, I am attaching snippet from my actual data.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;IF([Type]='Champion',0,IF(Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity])),(Sum([ Net Price])*Sum([Discount]))))&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krishna20_1-1604831719439.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/43774i8750A2F0A21DD629/image-size/large?v=v2&amp;amp;px=999" role="button" title="krishna20_1-1604831719439.png" alt="krishna20_1-1604831719439.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Just elaborating my expression, I have Type = 'Volume' not Champion. So, first condition fails and goes to else condition. Sum(Sales)=135,205 and LP* Quantity= 135,205. Second condition satisfies and should go to Netprice * Discount=14,499. But, It's displaying '-'.&lt;/P&gt;&lt;P&gt;I am not getting, how it is working in this situation &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 10:43:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759595#M453966</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-08T10:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759608#M453969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This could be a total red herring, but noting you have a space at the start of [ Net Price], is that actually in your fields or an issue when copying over? Do you get an error in the UI when you see '-' in text box?&lt;/P&gt;&lt;P&gt;I think in the original post you mentioned using in the load script - if you did not have appropriate grouping you would get Invalid Expression error, that might be worth investigating.&lt;/P&gt;&lt;P&gt;From experience I think you may also need to look at the order you sum in, depending how you aggregate, so if Discount were a percentage say I think I would expect to see Sum([Net Price]*[Discount]) rather than&amp;nbsp;Sum([Net Price])*Sum([Discount]) ... but there may be some quirks in your data model that are not obvious.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Chris.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 14:11:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759608#M453969</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2020-11-08T14:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759663#M453976</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;Thanks for yours input. As I already mentioned above in the comments, my first priority is to write the expression at front end only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the fields in the expression are correctly and it is not highlighting any error in the expression window.&lt;/P&gt;&lt;P&gt;This is very strange behavior I am facing with Qlik, no clue how it is working.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 04:35:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1759663#M453976</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-09T04:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1760415#M454016</link>
      <description>&lt;P&gt;Hey, I don't see any issue from your screenshot? Do you think this is not working as expected (I can assume only based on Measure titles)?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;IF([Type]='Champion',0,&lt;/FONT&gt;&lt;FONT color="#3366FF"&gt;IF(Sum([Sales])&amp;lt;=(Sum([LP])*Sum([Quantity]))&lt;/FONT&gt;,&lt;FONT color="#008000"&gt;(Sum([ Net Price])*Sum([Discount]))&lt;/FONT&gt;))&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From above, Red part will fail, So condition will fulfill from blue part and get the result of Green part? Is that not what you are expecting?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:59:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1760415#M454016</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-11-10T16:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: If Condition is not working as expected in script or expression</title>
      <link>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1765172#M454224</link>
      <description>&lt;P&gt;Hi Anil,&lt;/P&gt;&lt;P&gt;Yes, I need the green part to be calculated. I fixed this issue by taking all above expression to backend and group by with all the dimensions. Don't know why it was not calculating at front end even though the second condition satisfies. Thanks for your inputs and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/14825"&gt;@forte&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Krishna&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 05:50:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Condition-is-not-working-as-expected-in-script-or-expression/m-p/1765172#M454224</guid>
      <dc:creator>krishna20</dc:creator>
      <dc:date>2020-11-30T05:50:03Z</dc:date>
    </item>
  </channel>
</rss>

