Project Hub

Project · Stock reorder dashboard

Flagging 1,643 of 4,052 stock-outs in time to reorder

The problem

Best sellers run out before anyone notices while slow items fill the shelves, because stock is checked by hand and too late.

The solution

A daily pipeline loads sales and stock, works out days of cover and a reorder point per item, emails the morning reorder list, and shows stock risk in Power BI.

How it works

  • Load: Daily sales and stock per store and item into a warehouse, checked on every load
  • Forecast: Expected daily demand per item from recent sales
  • Rules: Days of cover, reorder point and safety stock written once, counting orders on the way
  • Alert: An email each morning listing the items to reorder and how many
  • Report: A Power BI stock report: what to reorder, what is empty, what sits too long

A closer look

Reorder email for one morning: a table of store, item, units on hand, units on order, days left, reorder point and the amount to order.
The reorder email, sent every morning.
Pipeline diagram: sales, stock and item files load into warehouse tables; materialized views work out the forecast and the stock rules for a reorder email and a Power BI stock report.
The daily pipeline, from the sales and stock files to the reorder list.
How a reorder alert works: one item's stock falls to the reorder point and the 7am email raises an alert; the delivery lands four days later, before the safety stock runs out, and when a later alert is ignored the shelf runs empty after seven days of warning.
One item's stock against two lines.
Data flow: one box per step, in run order, from the input files to the report.
The steps, in run order.
Star schema of the Power BI model: one fact table of 913,000 rows, one per day, store and item, joined to 1,826 dates, 10 stores, 50 items and 5 stock statuses.
One fact table, four small tables.
Airflow graph view of a daily stock_reorder run: load, forecast, rules and alert, all four tasks successful.
The Airflow DAG, run every morning.
Chart: stock-outs per month from 2013 to 2017, coming every summer and highest in July 2014; of 4,052 stock-outs, 1,643 were flagged in time to reorder.
Stock-outs per month, flagged in time or too late.

The code

@task
def rules():
    import pipeline
    pipeline.rules()

@task
def alert():
    import pipeline
    pipeline.alert()

load() >> forecast() >> rules() >> alert()
dags/stock_reorder.py

The impact

  • A reorder list in the 7am email every morning, with the store, item and amount to order.
  • Overstocked and slow items listed: 37% of stock value on the last day.
  • One rule for days of cover and safety stock, used by every store.

The result

913,000 sales rows: 1,643 of 4,052 stock-outs flagged in time to reorder, and 37% of stock value found in slow items.

Built with

  • Power BI
  • DAX
  • PostgreSQL
  • Python
  • Airflow