Recipe: Previous period from actuals
Most warehouses hold actuals with history and no “previous period” column. This recipe takes a CSV of monthly actuals per region and lets bino derive both comparisons: pp1 as the previous month and pp2 as the same month last year. A ChartTime shows actuals against last year, a Table shows all three, and the column captions come out as PP and PY without any translation manifest.
Project structure
Section titled “Project structure”Source
Section titled “Source”The CSV has one row per region and month, with month-end dates. Two years of history are enough for a full year of pp2:
Dataset
Section titled “Dataset”The query selects only what the source has: the dimension with its index twin, the actual and the date. No pp column appears in the SELECT; the two slots are declared instead.
grain: month says one row stands for a month. bino matches rows of the same identity - here region and regionIndex - whose month is one shift earlier, so 2024-03-31 finds 2024-02-29 for pp1 and 2023-03-31 for pp2. Rows without a prior period stay empty: January 2023 has no pp1, and all of 2023 has no pp2.
The chart compares the year; the table shows both comparisons and the absolute variance to last year.
What you get
Section titled “What you get”Run bino build. The table has three scenario columns and one variance column:
| Column | Caption | Why |
|---|---|---|
ac1 |
AC |
the engine default |
pp1 |
PP |
derived with shift: 1 month; a non-year shift is captioned PP |
pp2 |
PY |
derived with shift: 1 year; a year shift keeps the default PY |
dac1_pp2_pos |
ΔPY |
variance against pp2 |
The PP caption comes from a translation bundle bino synthesizes for the artefact’s language, because the engine labels every pp slot PY on its own. The rendered HTML carries it as:
Nothing is emitted for pp2. To caption either slot differently, add an Internationalization manifest; it is merged after the synthesized bundle, so it wins:
Checks you will see
Section titled “Checks you will see”- If the query window starts in 2023 and you ask for
pp2only, the build warns thatpp2is null on every row: the window has no prior year. - If two rows share
region,regionIndexand a month, the build fails withduplicate rows for identity …regardless of--data-validation. Aggregate to the grain in the query. - If you later add a
pp1column to theSELECTbut leavederive.pp1in place, the build fails: useassertfor a supplied slot. - A region that stops reporting keeps a row for the month after its last one, with an empty actual and its previous period filled, so the drop is visible; see How a row is matched.