atoti.measure module¶
- class atoti.measure.Measure(_name, _data_type, _cube, _java_api, _folder=None, _formatter=None, _visible=True, _description=None)¶
A measure is a mostly-numeric data value, computed on demand for aggregation purposes.
Measures can be compared to other objects, such as a literal value, a
Level
, or another measure. The returned measure represents the outcome of the comparison and this measure can be used as a condition. If the measure’s value isNone
when evaluating a condition, the returned value will beFalse
.Example
>>> df = pd.DataFrame( ... columns=["Id", "Value", "Threshold"], ... data=[ ... (0, 1.0, 5.0), ... (1, 2.0, None), ... (2, 3.0, 3.0), ... (3, 4.0, None), ... (4, 5.0, 1.0), ... ], ... ) >>> table = session.read_pandas(df, keys=["Id"], table_name="Measure example") >>> cube = session.create_cube(table) >>> l, m = cube.levels, cube.measures >>> m["Condition"] = m["Value.SUM"] > m["Threshold.SUM"] >>> cube.query(m["Condition"], levels=[l["Id"]]) Condition Id 0 False 1 False 2 False 3 False 4 True
- property folder: Optional[str]¶
Folder of the measure.
It can be changed by assigning a new value to the property (
None
to clear it).
- property formatter: Optional[str]¶
Formatter of the measure.
It can be changed by assigning a new value to the property (
None
to clear it).Examples
DOUBLE[0.00%]
for percentagesDOUBLE[#,###]
to remove decimalsDOUBLE[$#,##0.00]
for dollarsDATE[yyyy-MM-dd HH:mm:ss]
for datetimes
The spec for the pattern between the
DATE
orDOUBLE
’s brackets is the one from Microsoft Analysis Services. The formatter only impacts how the measure is displayed, derived measures will still be computed from unformatted value. To round a measure, useatoti.math.round()
instead.atoti provides an extra formatter for array measures:
ARRAY['|';1:3]
where|
is the separator used to join the elements of the1:3
slice.