<?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 Negation in Expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247381#M498368</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;I just want to ask if it is possible to do negation using an expression. I want to negate a boolean variable by clicking a button. I am using an If expression now, so I am really good without negation, but I just want to know if I am missing something. I should say I would rather not write a script...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried !, ~, Not()...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, has anyone seen an option of the button object that makes the button a toggle button?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 17:47:27 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-08-03T17:47:27Z</dc:date>
    <item>
      <title>Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247381#M498368</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;I just want to ask if it is possible to do negation using an expression. I want to negate a boolean variable by clicking a button. I am using an If expression now, so I am really good without negation, but I just want to know if I am missing something. I should say I would rather not write a script...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried !, ~, Not()...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, has anyone seen an option of the button object that makes the button a toggle button?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 17:47:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247381#M498368</guid>
      <dc:creator />
      <dc:date>2011-08-03T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247382#M498369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;NOT is negation.&amp;nbsp; if(not true(),'A','B') would return 'B'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure that's what you're asking for, though.&amp;nbsp; It sounds like you have a boolean expression somewhere already.&amp;nbsp; Based on a toggle button, you either want that expression, or the NOT of that expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For boolean, false()=0, true()=-1, but any non-zero is also considered true.&amp;nbsp; One way to negate a boolean, then, is to add 1 and mod 2.&amp;nbsp; Mod(true()+1,2) = 0 = false.&amp;nbsp; Mod(false()+1,2) = 1 = true.&amp;nbsp; We can also do this with our "new" value of true, mod(1+1,2) = false.&amp;nbsp; So to negate, we want to add 1.&amp;nbsp; To leave alone, we want to add 0.&amp;nbsp; If we had a toggle button that toggled between 0 and 1, it would toggle between negating and not.&amp;nbsp; And we've already seen how to swap between zero and 1, just add 1 and mod 2.&amp;nbsp; So then our toggle button can be a variable, and every time you press the button, add one and mod 2 to the variable.&amp;nbsp; Then for your condition, just add the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See attached.&amp;nbsp; I really don't know if that's what you wanted, though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 18:28:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247382#M498369</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-03T18:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247383#M498370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is one thorough solution... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I'm doing this on the button (setting &lt;EM&gt;vEnableLineBreak&lt;/EM&gt;)&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=If(vEnableLineBreak=False(), True(), False())&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your Mod solution is pretty close to what I wanted... Although I was hoping for a single function, so I could just write something like&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=Not(vEnableLineBreak)&lt;/EM&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: I love how you switch the color. A brilliant solution. hehe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Simon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 18:43:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247383#M498370</guid>
      <dc:creator />
      <dc:date>2011-08-03T18:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247384#M498371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, on the button itself, you can just do this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;=not vEnableLineBreak&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It'll then switch between 0 and -1, and have the same effect on the if() expressions.&amp;nbsp; I don't see how to simplify the if() expressions, though, and was just being consistent between the button and the expressions on my negation approach.&amp;nbsp; Perhaps simplicity is better than consistency here, and definitely if ALL you wanted was that button, I'd got with the NOT approach.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 18:49:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247384#M498371</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-03T18:49:24Z</dc:date>
    </item>
    <item>
      <title>Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247385#M498372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can toggle a boolean variable with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=NOT varname&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 18:57:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247385#M498372</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-08-03T18:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247386#M498373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thinking further, I think the following approach might be more clear, as it doesn't depend on mathematical games or on the internal storage format of boolean values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you click the button, set value to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;=if(Negate='NOT','','NOT')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in your if() expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if($(Negate) (Your boolean expression here), true result, false result)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 19:10:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247386#M498373</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-03T19:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247387#M498374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok. How could I miss that?&amp;nbsp; Thanks for pointing that out...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I was also making another error in the beginning, I was setting the variable, vEnableLineBreak, to True, which was not interpreted as a boolean variable in the expression. Instead, I should have stored the value as an integer...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks to you both... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 19:11:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247387#M498374</guid>
      <dc:creator />
      <dc:date>2011-08-03T19:11:05Z</dc:date>
    </item>
    <item>
      <title>Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247388#M498375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just saw you have a toggle button example in your cookbook available on your website: robwunderlich.com/downloads... I think there should be a mention of that in this discussion... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Aug 2011 23:37:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247388#M498375</guid>
      <dc:creator />
      <dc:date>2011-08-06T23:37:22Z</dc:date>
    </item>
    <item>
      <title>Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247389#M498376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for pointing out the "User selected on/off true/false switches" button example in the Cookbook. That example uses &lt;/P&gt;&lt;P&gt;=vShow * -1 -1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to do the toggle. &lt;/P&gt;&lt;P&gt;=NOT vShow&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is a little simpler, which I why I didn't point out the example. The next version of the cookbook wlll have the simpler form.&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://robwunderlich.com"&gt;http://robwunderlich.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Aug 2011 15:50:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247389#M498376</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2011-08-07T15:50:44Z</dc:date>
    </item>
    <item>
      <title>Negation in Expression</title>
      <link>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247390#M498377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Doh!&amp;nbsp; Much better.&amp;nbsp; I'd probably write it like this, but same idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-(vShow+1)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2011 16:21:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Negation-in-Expression/m-p/247390#M498377</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-08-08T16:21:51Z</dc:date>
    </item>
  </channel>
</rss>

