IF
Category: Logical functions
Overview
The IF function evaluates a condition and returns one value when the condition is true and another when it is false. For every row of the input, the condition is evaluated independently.
Use this function to implement business rules such as thresholds, caps, floors, or other conditional logic.
Syntax
IF(Condition)returns the condition’s value where true and no value where false.IF(Condition, ValueIfTrue)returns ValueIfTrue where true and no value where false.IF(Condition, ValueIfTrue, ValueIfFalse)returns one value for true and another for false.
Example usage: IF('Margin' < 0, 0, 'Margin')
Parameters
Parameter | Description | Type | Required |
|---|---|---|---|
Condition | A node evaluated to true or false. | Node reference | Yes |
ValueIfTrue | Value returned when the condition is true. | Number / Node ref | No |
ValueIfFalse | Value returned when the condition is false. | Number / Node ref | No |
Building conditions
Conditions can be written as operators or with logical functions. Most users write the operator form directly in formulas.
Operator | Function | Meaning |
|---|---|---|
| equal | |
| not equal | |
| greater than | |
| greater than or equal | |
| less than | |
| less than or equal | |
| both conditions true | |
| at least one true | |
invert condition | ||
value is undefined |
For details and pitfalls, see Comparisons & boolean operators.
Output Shape
Aspect | Behavior |
|---|---|
Dimensionality | Union of all input dimensionalities. Per dimension, the finest granularity across the condition, ValueIfTrue, and ValueIfFalse is used. |
Row count | Depends on the form used. With all 3 arguments, the output contains one row per condition row (true rows get ValueIfTrue, false rows get ValueIfFalse). With 1 or 2 arguments, rows where the condition is false are dropped (become N/A). |
Values | The condition is evaluated independently for each row |
Watch Out
When all three arguments are provided, if ValueIfTrue or ValueIfFalse has finer dimensionality than the condition, both must have the same dimensionality. This check does not apply to the 1- or 2-argument form.
0 is interpreted as false, any other value as true.
When IF returns N/A, the cell appears empty in tables and is excluded from charts. This is different from returning 0. N/A means "no value exists," while 0 is a real numeric value.
Examples
Dividend payout
Dividends are only paid in years with positive net income.
The payout equals 50 % of net income.
Input node: Dividend Payouts / Net Income
Value |
|---|
50% |
Input node: Net Income
Year | Value |
|---|---|
2025 | -30 |
2026 | 20 |
2027 | -10 |
2028 | 0 |
2029 | 100 |
Formula: IF('Net Income' > 0, 'Net Income' * 'Dividend Payouts / Net Income', 0)
Year | → IF Result |
|---|---|
2025 | 0 |
2026 | 10 |
2027 | 0 |
2028 | 0 |
2029 | 50 |
Dividends are only paid in years with positive net income.
Example calculations:
2026 → 20 × 50 % = 10
2029 → 100 × 50 % = 50
Floor at zero
Negative margins should be reported as 0.
Input node: Margin
Year | Value |
|---|---|
2025 | 15 |
2026 | -8 |
2027 | 22 |
2028 | -3 |
Formula: IF('Margin' < 0, 0, 'Margin')
Year | → IF Result |
|---|---|
2025 | 15 |
2026 | 0 |
2027 | 22 |
2028 | 0 |
IF used as a condition check
When only the condition is provided, IF returns 1 when the condition is true and no value (N/A) when it is false.
Input node: Revenue
Year | Revenue |
|---|---|
2025 | 800 |
2026 | 1200 |
2027 | 1500 |
2028 | 600 |
Formula: IF('Revenue' > 1000)
Year | → IF Result |
|---|---|
2026 | 1 |
2027 | 1 |
In this example, the comparison 'Revenue' > 1000 evaluates to 1, which is what IF returns. If you use IF('Revenue') directly, it returns Revenue's own value for non-zero rows.
This pattern is useful when creating binary helper tables or flags for further filtering or visualization.
Using IF(Node) to remove zero values
When a node itself is used as the condition, IF checks whether the value is true (non-zero) or false (zero).
Because IF interprets 0 as false, those entries become N/A in the result.
Input node: Revenue
Year | Revenue |
|---|---|
2025 | 0 |
2026 | 120 |
2027 | 0 |
2028 | 300 |
Formula: IF('Revenue')
Year | → IF Result |
|---|---|
2026 | 120 |
2028 | 300 |
This technique replaces zeros with N/A values, which can help avoid misleading totals and reduce visible rows in tables and charts.