Inventory snapshots
Stock is a balance, not a flow
Inventory at a month end is a periodic snapshot: one row per product and period. It is additive across products on the same date, but not across time. Use the isolated model in labs/business-kpis/README.md. All amounts are fictional USD, with costs stored as positive expenses. Three complete sales months (January–March 2025), monthly Periods, two Products, single-direction active relationships to both facts, no RLS. Examples are independent measure definitions unless labeled otherwise. Native DAX is not executed. The inventory policy is strict: both selected products must have exactly one nonblank balance at the last visible month. A missing row means unknown, and an explicit zero means known out of stock. All inventory values are in units. Unique product-period keys and nonnegative balances are fixture prerequisites.
Example 1 — Select a common closing month
Snapshot Units = SUM(Inventory[StockUnits])Strict Closing Stock =VAR Anchor = MAX(Periods[MonthStart])VAR Expected = COUNTROWS(VALUES(Products[ProductID]))VAR Observed = CALCULATE(COUNT(Inventory[StockUnits]), REMOVEFILTERS(Periods), Periods[MonthStart] = Anchor)RETURN IF(NOT ISBLANK(Anchor) && Expected > 0 && Observed = Expected, CALCULATE([Snapshot Units], REMOVEFILTERS(Periods), Periods[MonthStart] = Anchor), BLANK())January A=10 and B=20, total 30. February A=8, B=0, total 8. March A=6, B missing, total BLANK. With all months selected the closing month is March; the grand total is BLANK, not 44 or 6. With A alone the result is 6. COUNT counts the numeric zero; a missing row or blank balance does not count. The guard relies on verified unique keys: duplicate rows must be rejected upstream.
Example 2 — Explicit earlier complete snapshot
Last Complete Stock =VAR Anchor = MAX(Periods[MonthStart])VAR Eligible = FILTER(ALL(Periods), Periods[MonthStart] <= Anchor && NOT ISBLANK(CALCULATE([Strict Closing Stock])))VAR LastComplete = MAXX(Eligible, Periods[MonthStart])RETURN IF(NOT ISBLANK(LastComplete), CALCULATE([Strict Closing Stock], REMOVEFILTERS(Periods), Periods[MonthStart] = LastComplete))For both products in March, this finds February and returns 8. For A alone it finds March and returns 6. For B alone it finds February and returns 0. Label this explicitly as last complete stock and show its as-of date; it is not the March balance. The rule may look before the current selected period, but never after the anchor. Totals for different selected product sets may use different dates, so they are not additive across those sets.
Common mistakes — stale and partial balances
LASTDATE identifies the final visible date, not necessarily the last loaded stock. LASTNONBLANK can identify a nonblank expression but cannot establish complete product coverage unless the expression enforces it. Never add monthly stock balances as if they were sales. Do not mix product A March with B February and label the result a single month-end total. Show a missing-data status and the as-of date; this lab deliberately avoids last-observation-per-product carry-forward.
Practice — Audit closing balances
For all products and for B alone, compare the strict closing balance and last complete balance in February and March. Explain how the model distinguishes an explicit zero from an absent row. Add a proposed March B value of 3 in a copy; predict the new strict March total and verify that prior months do not change.
References and next steps
See snapshot fact guidance, LASTDATE and LASTNONBLANK. Next: distinguish cumulative counts and retention.