> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# atoti.last()

### atoti.last(measure, on, /, \*, partitioning=None)

Return a measure equal to the last value of the passed measure on the given level.

* **Parameters:**
  * **measure** (*VariableMeasureConvertible*) – The measure to shift.
  * **on** ([*Level*](./atoti.level#atoti.Level)) – The level to shift on.
  * **partitioning** ([*Level*](./atoti.level#atoti.Level) *|* *None*) – The level in the hierarchy at which to start over.
* **Return type:**
  *MeasureDefinition*

### Example

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> from datetime import date
>>> df = pd.DataFrame(
...     columns=["Date", "Quantity"],
...     data=[
...         (date(2019, 7, 2), 15),
...         (date(2019, 7, 1), 20),
...         (date(2019, 6, 1), 25),
...         (date(2019, 6, 2), 15),
...         (date(2019, 6, 30), 5),
...     ],
... )
>>> table = session.read_pandas(df, table_name="CumulativeTimePeriod")
>>> cube = session.create_cube(table, mode="manual")
>>> l, m = cube.levels, cube.measures
>>> cube.create_date_hierarchy("Date", column=table["Date"])
>>> m["Quantity.SUM"] = tt.agg.sum(table["Quantity"])
>>> m["Quantity last day"] = tt.last(m["Quantity.SUM"], l["Day"])
>>> m["Quantity last day of month"] = tt.last(
...     m["Quantity.SUM"], l["Day"], partitioning=l["Month"]
... )
>>> cube.query(
...     m["Quantity.SUM"],
...     m["Quantity last day"],
...     m["Quantity last day of month"],
...     levels=[l["Day"]],
...     include_totals=True,
... )
                Quantity.SUM Quantity last day Quantity last day of month
Year  Month Day
Total                     80                15
2019                      80                15
      6                   45                15                          5
            1             25                15                          5
            2             15                15                          5
            30             5                15                          5
      7                   35                15                         15
            1             20                15                         15
            2             15                15                         15
```
