atoti.date_shift(Return a measure equal to the passed measure shifted to another date.
measure: VariableMeasureConvertible,
on: Hierarchy,
/,
*,
offset: str,
dense: bool =False,
fallback: Literal[‘past’, ‘interpolated’, ‘future’] | None =None,
) → MeasureDefinition
Parameters
measure
The measure to shift.on
The hierarchy to shift on. Only hierarchies with their last level with adata_type of "LocalDate" or "LocalDateTime" are supported.
offset
The period to shift by as specified by Java’s Period.parse().dense
IfFalse, the returned measure will evaluate to None everywhere the input measure evaluates to None.
If True, the returned measure will be evaluated on all the queried members of the on hierarchy, even if the input measure evaluates to None there.
In any case, facts are never “created”: if measure evaluates to a non-None value on 2025-01-01 and offset="-P2D" but 2025-01-03 is not a member of the on hierarchy, 2025-01-03 will remain absent from the query results.
fallback
The value to use if measure evaluates toNone at the shifted location:
None: No value.past: Value at the previous date in chronological order.interpolated: Linear interpolation of the values at the past and future existing dates orNoneif either date is missing.future: Value at the next date in chronological order.
- Exact (+):
- The value for 2020-08-31 is taken from 2020-09-30 even though
31 != 30because there are both the last day of their respective month.
- The value for 2020-08-31 is taken from 2020-09-30 even though
- Exact (-):
- The value for 2020-10-31 is taken from 2020-09-30 for the same reason.
- Interpolated:
- 10.00, 21.00, 21.00, and 9.00: no interpolation required since there is an exact match.
- 15.31: linear interpolation of 2020-09-01’s 10 and 2020-09-30’s 21 at 2020-09-15.
- 8.03: linear interpolation of 2020-10-01’s 9 and 2020-10-31’s 8 at 2020-10-30.
- ∅: no interpolation possible because there are no records after
2020-10-31.
- Sparse:
- There is no value for (2020-09-01, London) because, although both members exist separately, no fact contains both simultaneously.
- Dense:
- The value for (2020-09-01, London) is taken from (2020-10-01, London).
- There are no values for 2020-10-01 because 2020-11-01 is not a member of the Date hierarchy.
See also:
shift().