Skip to main content
@overload
atoti.where(
    condition: ColumnCondition,
    true_value: ColumnConvertible,
    false_value: ColumnConvertible | None = None,
    /,
) → Operation[ColumnIdentifier]
@overload
atoti.where(
    condition: VariableMeasureConvertible,
    true_value: MeasureConvertible,
    false_value: MeasureConvertible | None = None,
    /,
) → MeasureDefinition
@overload
atoti.where(
    condition_to_value: Mapping[VariableMeasureConvertible, MeasureConvertible],
    /,
    *,
    default: MeasureConvertible | None = None,
) → MeasureDefinition
Return a conditional measure. This function is like an if-then-else statement:
  • Where the condition is True, the new measure will be equal to true_value.
  • Where the condition is False, the new measure will be equal to false_value.
If false_value is not None, true_value and false_value must either be both numerical, both boolean or both objects. If one of the values compared in the condition is None, the condition will be considered False. Different types of conditions are supported:
  • Measures compared to anything measure-like:
  • Levels compared to levels, (if the level is not expressed, it is considered None):
  • Levels compared to constants of the same type:
  • A conjunction or disjunction of conditions using the & operator or | operator:
When a mapping of condition to value is passed, the resulting value is the one of the first condition evaluating to True:

Parameters

condition

VariableMeasureConvertible

true_value

MeasureConvertible

false_value

MeasureConvertible | None

condition_to_value

Mapping[VariableMeasureConvertible, MeasureConvertible]

default

MeasureConvertible | None

See also: atoti.switch().