How to calculate SaaS Magic Number
The SaaS magic number compares the revenue growth in one quarter with the sales and marketing spend of the quarter before.
Formula
Magic number = (revenue this quarter − revenue last quarter) × 4 ÷ sales and marketing spend last quarterSQL query
This example assumes: quarterly_financials(quarter date, revenue numeric, sales_marketing_spend numeric). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
SELECT quarter,
revenue,
(revenue - LAG(revenue) OVER (ORDER BY quarter)) * 4
/ NULLIF(LAG(sales_marketing_spend) OVER (ORDER BY quarter), 0) AS magic_number
FROM quarterly_financials
ORDER BY quarter;Common mistakes that make SaaS Magic Number wrong
- Some teams use subscription revenue and others total revenue; pick one and keep it.
- Spend is lagged by one quarter on purpose; using same-quarter spend gives a different number.
- One-off revenue (services, true-ups) distorts the quarter-on-quarter change.
Ask for SaaS Magic Number in plain English
Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.
- What was our SaaS magic number for each of the last 8 quarters?
- How did sales and marketing spend change quarter on quarter?