Skip to content

Build a what-if model

Write a decision as a small model of what you control, what you don't, and what you care about, then move it to see what changes.

Introductory ~11 min7 steps

What runs in CodeSplash

You will be able to

  • Sort a problem into decisions, uncertain inputs, formulas and KPIs
  • Compute a model's result at its base values
  • Use what-if sliders, and say what they can't show
01

How much should you order?

Read

You sell a seasonal product. You order once, before you know the demand. Order too little and you lose sales. Order too much and you're left with stock.

Four parts make a model of this:

  • Decision: what you control. The order size.
  • Inputs: what you don't control. Demand and price.
  • Formulas: how they connect. Sales are the smaller of demand and order.
  • KPI: what you care about. Profit.
profit=price×min⁡(demand,order)−6×order\text{profit} = \text{price} \times \min(\text{demand}, \text{order}) - 6 \times \text{order}
02

Sort them

Checkpoint

Check yourself

You're planning a marketing budget. Which of these is an uncertain input?

Show the answer

Answer: b

You choose the spend, so that's a decision. Customer response is outside your control, and uncertain, so it's an input.

Check yourself

Which makes the better KPI for a stocking model?

Show the answer

Answer: a

A KPI is an outcome the model computes. Order size is a decision, and demand is an input.

03

Run the numbers

Checkpoint

Say demand is 1,000 and you order 1,100, at a unit cost of 6. Price follows a triangular distribution from 9 to 12, most likely 10, whose mean is (9+10+12)/3=10.33(9 + 10 + 12) / 3 = 10.33.

Check yourself

What's the profit at those values? Round to the nearest whole number.

Show the answer

Answer: 3733.33333333333

Sales = min(1,000, 1,100) = 1,000. Profit = 10.33 × 1,000 − 6 × 1,100 = 10,333 − 6,600 = 3,733.

04

Move the decision

Explore

Here's a similar stocking problem with its own prices. Move your order, up and down from average demand.

DExplorable · The newsvendor

When demand is uncertain, should you order more or less than you expect to sell?

With these margins, should you order more or less than average demand?

How sure?
20.0
8.0
2.0
1000
200
1000
bestaverage demand
  • Your order: 1000

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Does profit fall at the same rate on both sides? It usually doesn't. That's why the best order is rarely the average demand: it depends on how a lost sale compares with a leftover unit.

05

What a slider can't tell you

Predict

Predict first

Your slider says that at the average demand and price, an order of 1,100 makes about 3,733. Is that what you should expect to earn?

Yes: profit will be near that numberNot necessarily: demand may differ from 1,000 either way
Reveal

Not necessarily. Sales can't exceed what you stocked, so high demand can't make up fully for low demand. The next lessons show that the average outcome falls below the outcome at average inputs.

06

Build one

In the app

In Studios, open Scenarios & optimization and choose Inventory (newsvendor). It needs no dataset. The Model step lists the inputs, decisions, formulas and KPIs. Each input can take a three-point estimate, or be fitted to a dataset column. The What-if step has the sliders.

This tour moves a decision, saves a scenario and simulates it.

07

Recap

Recap
  • A model separates what you control from what you don't, and ties them to what you care about.
  • What-if shows how the result moves at particular values.
  • Results at average inputs aren't average results, which is what simulation is for.