IF
Basic Overview
Description | Checks if the condition is true and uses the first value of the condition for every row (value_if_true). If the condition is false the second value of the condition (value_if_false) is used for every row. |
|---|---|
Signature | IF(condition[, value_if_true[, value_if_false]]) |
Parameters | condition is a cube or expression that is validated to either true or false. The value of 0 is interpreted as false and all other values are interpreted as true. Comparisons inside of conditions can be configured with logical functions. value_if_true will be chosen when the condition is validated to true. Available since 3.5.0: If this parameter is not present, the function result is the same as if the function was 'IF(condition, condition)'. value_if_false will be chosen when the condition is validated to false. value_if_true and value_if_false need to have the same dimensionality, if they are more fine-granular than the condition. |
Example
Dividends Pay-Out
With earnings, we pay out 50% of our net income to shareholders. Simple If formula with greater than logical function solves the task.
Dividend Payouts / Net Income
Value |
|---|
50% |
Net Income
Year | Value |
|---|---|
2016 | -30 |
2017 | 20 |
2018 | -10 |
2019 | 0 |
2020 | 100 |
Dividend Paid = IF( 'Net Income' > 0, 'Net Income' * 'Dividend Payouts / Net Income', 0)
Year | Value |
|---|---|
2016 | 0 |
2017 | 10 |
2018 | 0 |
2019 | 0 |
2020 | 50 |