# Comparisons & boolean operators
URL: https://docs.valsight.ai/comparisons-boolean-operators/
Description: Comparisons and boolean operators turn values into conditions. Use them to test values, combine conditions, and drive branching logic, most commonly inside IF.
Comparisons and boolean operators **turn values into conditions**. Use them to test values, combine conditions, and drive branching logic, most commonly inside `IF`.

They return `1` for true and `0` for false.

## Start here if…

* You want to write a condition such as `'Revenue' > 1000`
* You want to combine conditions with `AND`, `OR`, `NOT`, `XOR`
* You need a `TRUE` / `FALSE` helper function
* You’re writing the condition part of `IF(condition, value_if_true, value_if_false)`

## Not here if…

* You are searching the catalog for a function page by name such as `GT`, `EQ`, `AND`, or `IS_NA` → see [Logical functions](/logical-functions/)
* You want branching behavior and examples for `IF` specifically → see [IF](/if/)

## Mental model

* Comparisons compare matching rows and return 1 (true) or 0 (false)
* Boolean operators combine or invert conditions and also return 1 or 0
* `TRUE('Node')`/ `FALSE('Node')` returns 1/0 wherever `'Node'` is defined
* `IS_NA('Node')` returns 1 where `'Node'` is undefined (and can expand result size)
* In `IF`, 0 is interpreted as false and any other value as true

## Comparison operators

| Operator | Function equivalent     | Details           | Returns 1 when…                        |
| -------- | ----------------------- | ----------------- | -------------------------------------- |
| `=`      | `EQ('Node1', 'Node2')`  | [EQ (=)](/eq/)    | values are equal                       |
| `!=`     | `NEQ('Node1', 'Node2')` | [NEQ (!=)](/neq/) | values are not equal                   |
| `>`      | `GT('Node1', 'Node2')`  | [GT (>)](/gt/)    | left is greater than right             |
| `>=`     | `GTE('Node1', 'Node2')` | [GTE (>=)](/gte/) | left is greater than or equal to right |
| `<`      | `LT('Node1', 'Node2')`  | [LT (<)](/lt/)    | left is less than right                |
| `<=`     | `LTE('Node1', 'Node2')` | [LTE (<=)](/lte/) | left is less than or equal to right    |

Many comparisons can be written either as a function call or as an operator expression, for example `GT('Node1', 'Node2')` or `'Node1' > 'Node2'`.

## Boolean operators

| Operator      | Function equivalent     | Details           | Returns 1 when…            |
| ------------- | ----------------------- | ----------------- | -------------------------- |
| `AND` / `&&`  | `AND('Node1', 'Node2')` | [AND (&&)](/and/) | both inputs are true       |
| `OR` / `\|\|` | `OR('Node1', 'Node2')`  | [OR (\|\|)](/or/) | at least one input is true |
| `NOT`         | `NOT('Node')`           | [NOT](/not/)      | input is false (0)         |
| `XOR`         | `XOR('Node1', 'Node2')` | [XOR](/xor/)      | exactly one input is true  |

These operators are most commonly used inside `IF` conditions.

## Defined/undefined helper functions

| Function        | Details           | Returns                      |
| --------------- | ----------------- | ---------------------------- |
| `TRUE('Node')`  | [TRUE](/true/)    | 1 on defined intersections   |
| `FALSE('Node')` | [FALSE](/false/)  | 0 on defined intersections   |
| `IS_NA('Node')` | [IS\_NA](/is-na/) | 1 on undefined intersections |

## Common patterns

| Name                            | What it does                                                            | Formula                                                |
| ------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------ |
| Flag positive values            | Returns 1 where the value is above zero, else 0.                        | `'Value' > 0`                                          |
| Combine conditions              | True when either condition holds.                                       | `('Margin' < 0) OR ('Revenue' = 0)`                    |
| Branching logic                 | Returns one value where the condition holds, another where it does not. | `IF('Net Income' > 0, 'Net Income' * 'PayoutRate', 0)` |
| Truthiness shortcut             | Treats any non-zero value as true.                                      | `IF('Delta', 1, 0)`                                    |
| Check whether a node is defined | Uses `TRUE` as the condition to select defined cells.                   | `IF(TRUE('Sales'), 'Node1', 'Node2')`                  |
| Find missing intersections      | Returns 1 where the node is undefined.                                  | `IS_NA('Sales')`                                       |

## Pitfalls & troubleshooting

* **Truthiness surprises**: in conditions, `0` is false and any non-zero value is true
* **Defined vs undefined**: `TRUE('Node')` and `FALSE('Node')` apply where the node is defined; use `IS_NA('Node')` to detect undefined intersections
* **Cube size risk**: `IS_NA` can expand result size significantly
* **Dimensional mismatch**: some logical functions, such as `XOR`, may behave unexpectedly when inputs differ in granularity

## Related documentation

* [IF](/if/): how conditions are interpreted in `IF`
* [Formula basics](/formula-basics/): parentheses, evaluation order, and quoting rules
* [Troubleshooting guide](/troubleshooting-guide/): wrong shape, wrong numbers, empty output, and missing values
