Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Basically just the title. I don't at all see the point of it, and it causes issues when you multiply them (true * true != true), and also summing them returns a negative value.
Please fill me in.
The reason for this is that -1 is equivalent to setting all the bits in the byte to 1, which is how TRUE is represented in most software systems (as opposed to FALSE, where all bits are set to 0). This is different from other languages where booleans are represented as 1 and 0. However, it is important to note that in situations where Qlik expects a Boolean, such as in the first parameter of the if() function or in a Where clause, Qlik will interpret 0 as FALSE, and all other numbers as TRUE. This means that a number of functions can be used as either Boolean or numeric functions, such as Index(), Match(), Substringcount(), and FieldIndex().
Please refer to the following posts below where other users have touched upon a similar question
Why is true represented by '-1'and not '1' in some... - Qlik Community - 1386348
On Boolean Fields and Functions - Qlik Community - 1462815
In each case where you want to use the flag as multiplicator or (range) summing it you could simply reverse the direction of the value by the flag-creation, like:
-(month(Date)=month(today())) as InMonthFlag
and you will get 0 or 1 as results.
Obviously there are ways around it, but I was asking why it was set up like it is