Sales Scenario Analysis
Connect ordinary worksheet data to a reactive Python notebook with pandas, explore pricing scenarios using interactive controls, and publish calculated summary tables back to Excel.
- Edit the spreadsheet: Change any number in the blue worksheet cells (
A5:C9— Units or Price). - Move the slider: Drag the Discount scenario (%) slider in the Python notebook on the right.
- Observe the flow: Notice how the Matplotlib chart re-renders immediately and the green worksheet summary (
BF.OUTPUT("summary")) updates automatically.
Need more space? Click Open in separate tab on the workbook header to test in a dedicated browser window.
Live interactive workbook
How the notebook architecture works
This starter example demonstrates the core four-step lifecycle of Boardflare Python for Excel:
1. Excel remains the source of truth
The workbook retains the durable operational data in cells A5:C9. The notebook connects to this range with:
inputs = bf.inputs(sales=bf.ref("A5:C9", headers=True))
Whenever you edit values in the worksheet, Boardflare pushes the updated range directly into the marimo dependency graph as a pandas DataFrame.
2. Reactive calculation in normal Python
The analysis runs in a marimo reactive notebook cell:
analysis = inputs["sales"].copy()
analysis["Base revenue"] = analysis["Units"] * analysis["Price ($)"]
analysis["Scenario revenue"] = analysis["Base revenue"] * (1 - float(discount.value) / 100)
The discount slider is a notebook UI control (mo.ui.slider). Adjusting the slider recomputes dependent cells without altering the underlying worksheet assumptions.
3. Publishing results back to Excel
The calculated scenario metrics are published back to the workbook:
bf.publish(outputs={"summary": summary})
In Excel, cell E5 displays this live result using the formula:
=BF.OUTPUT("summary")
Notebook charts and detailed diagnostics stay inside the notebook, while Excel receives only the clean, published summary table.
What to try next
- Explore Demand & Inventory Planner for multi-sheet modeling, constrained budget optimization, and custom
BF.FUNCTION()formulas. - Explore Curve Fitting for scientific regression, SciPy parameter estimation, confidence bands, and residual diagnostics.
- Ready to use notebooks in your own spreadsheets? Follow the Getting started guide.