Marc has explored the data, trained models and drawn charts. Irene, the head of data, now puts to him the question that justifies the whole platform: "Very good, but what do I have to look at every morning to know whether NovaMarket is doing well, and what do I do if it isn't?".
This lesson covers the last stretch of the journey, the one that goes from the figure to the decision. You will learn to tell a piece of data from a metric and from a KPI, to define indicators that cannot be interpreted in two ways, to calculate them on the lake and to organise them into a dashboard. You will also see two analysis techniques that accompany any indicator, cohorts and A/B tests, and how to communicate a finding so that someone acts on it. It brings the analysis module to a close.
Data, metric and KPI
The three terms are used as synonyms, and they are not:
| Concept | What it is | Example at NovaMarket |
|---|---|---|
| Data | A recorded fact, unprocessed | Order 788, for €2,145.97, delivered, placed through the app |
| Metric | A measure calculated from the data, with a formula | Number of orders in the day; average amount per order |
| KPI (key performance indicator) | A metric chosen because it measures progress towards a business objective, with a target and an owner | Conversion rate, with a target of 12.5% |
Every KPI is a metric, but very few metrics deserve to be KPIs. The important word is key: a company can calculate thousands of metrics, but it can only manage with a handful. If a dashboard shows forty "key" indicators, none of them is.
How to define a good KPI
Most arguments about figures in a company are not arguments about the business, but about definitions. "Conversion is 12%." "No, it's 23%." Both are right: they are measuring different things under the same name. A well-defined KPI specifies six things:
| Element | Question it answers |
|---|---|
| Objective | Which business objective does it monitor? What decision does it help to make? |
| Formula | What exactly is divided by what? What is included and what is excluded? |
| Grain | At what level of detail is it calculated (day, week) and by which dimensions can it be broken down? |
| Source | Which table does it come from? |
| Owner | Who answers for its value and who for its calculation? |
| Threshold | What is the target? From what value onwards should you worry? |
All of this is recorded in a definition card. The one for NovaMarket's conversion rate:
KPI: Conversion rate
------------------------------------------------------------------------------
Objective Measure how effectively the shop turns visits into purchases.
Decisions: prioritise improvements to the website and the app.
Formula sessions that complete the funnel / total sessions x 100
A session completes the funnel if it has at least one product
view, one add to cart and one purchase.
Includes anonymous sessions. Does not exclude internal traffic or bots.
Grain Daily. Can be broken down by device.
Source gold/daily_funnel (columns with_purchase and sessions)
Owner Business: e-commerce management. Calculation: data team (Marc).
Threshold Target: 12.5%. Alert: below 11% for 3 days in a row.
Freshness Available at 06:00 with the previous day's data.
Notes A session that crosses midnight counts on two days.
The current period is provisional.Each line prevents a future misunderstanding. The one most often neglected is notes and exclusions, which is precisely the one that explains why two figures do not match.
Three more criteria distinguish a good KPI:
- It is a ratio or a rate rather than a total. A total grows simply with the size of the business; a rate makes it possible to compare days, channels or countries.
- It has a counterweight. Any indicator can be improved by cheating: conversion goes up if you stop attracting new traffic. That is why KPIs are monitored in pairs with another one that would expose the side effect (conversion alongside sessions; revenue alongside return rate).
- You can act on it. If nobody can do anything to move it, it is a curiosity.
Vanity metrics and actionable metrics
A vanity metric is one that makes you look good but does not help you decide: it almost always grows, it is not linked to any objective and it does not tell you what to do. An actionable metric changes when the business improves or deteriorates and suggests where to intervene.
| Vanity metric | Why it misleads | Actionable alternative |
|---|---|---|
| Registered customers: 2 million | It is cumulative: it can only go up, even if nobody buys | Customers active in the last 30 days; customers at risk of churning |
| Page views: 140,000 product views in June | More views do not mean more sales | Conversion rate; cart abandonment |
| App downloads | An app downloaded and never opened is worth nothing | Percentage of orders placed through the app |
| Total revenue since launch | Another cumulative figure | Revenue for the period compared with the previous period and the target |
The test for telling them apart is a single question: if this figure changed tomorrow, would we do anything differently? If the answer is no, it has no place on the dashboard.
NovaMarket's metric tree
KPIs are not a loose list: they are related to one another. A metric tree breaks down the main indicator, the so-called north star metric, into the factors that produce it. In e-commerce, the classic breakdown is:
Revenue = Sessions × Conversion rate × Average order value
flowchart TD
I["Net revenue"] --> B["Gross revenue"]
I --> D["− Returns<br>(return rate)"]
B --> P["Orders"]
B --> T["× Average order value"]
P --> S["Sessions"]
P --> C["× Conversion rate"]
S --> S1["Traffic by channel and device"]
C --> C1["View → cart"]
C --> C2["Cart → purchase<br>(cart abandonment)"]
T --> T1["Units per order"]
T --> T2["Average price per unit"]
The tree serves two purposes:
- Diagnosing. If revenue falls, you go down the branches: are there fewer sessions, are they converting worse or are customers spending less? Each answer points to a different team (marketing, product, pricing).
- Estimating the effect of an improvement. Because the branches multiply, one more point of conversion (from 12.1% to 13.1%) means 8% more orders; with €5.4 million gross a month, about €450,000 a month. The tree turns "improving the website" into a figure.
A caveat with the practice data. In a real shop, sessions × conversion gives the orders. Not here: the web events and the orders are two sources generated independently (lesson 01-05), and in June there are 3,735 sessions that complete the funnel against 3,226 orders. The tree is correct as a model; do not expect the multiplication to tally with these tables.
Calculating the KPIs on the lake
NovaMarket's KPIs will be calculated once a day and saved in a new gold table, gold/daily_kpis, with one row per day. These are the definitions:
| KPI | Formula | Source |
|---|---|---|
| Sessions | Sessions in the day | gold/daily_funnel |
| Conversion rate | Sessions that complete the funnel / sessions | gold/daily_funnel |
| Cart abandonment | Sessions with a cart that do not buy / sessions with a cart | gold/daily_funnel |
| Orders | Orders in the day, in any status | silver/orders_complete |
| Revenue (net) | Amount of the orders not returned | silver/orders_complete |
| Average order value | Average amount per order | silver/orders_complete |
| Return rate | Returned orders / orders, by order date | silver/orders_complete |
| Returning customers | Customers who buy that day and had already bought before / customers who buy that day | silver/orders_complete |
Create ~/novamarket/compute_kpis.py:
"""Calculates NovaMarket's daily KPIs and saves them in gold/daily_kpis.
Usage: python compute_kpis.py
Recalculates the whole table: it is idempotent.
"""
from pathlib import Path
from pyspark.sql import SparkSession
LAKE = Path.home() / "novamarket" / "lake"
spark = SparkSession.builder.master("local[*]").appName("compute_kpis").getOrCreate()
spark.sparkContext.setLogLevel("ERROR")
spark.read.parquet(str(LAKE / "silver" / "orders_complete")).createOrReplaceTempView("orders")
spark.read.parquet(str(LAKE / "gold" / "daily_funnel")).createOrReplaceTempView("funnel")
kpis = spark.sql("""
WITH first_order AS ( -- date of each customer's first order
SELECT customer_id, MIN(CAST(order_date AS DATE)) AS first_date
FROM orders
GROUP BY customer_id
),
sales AS ( -- KPIs derived from the orders
SELECT CAST(o.order_date AS DATE) AS date,
COUNT(*) AS orders,
ROUND(SUM(IF(o.status <> 'returned', o.total_amount, 0)), 2) AS revenue,
ROUND(AVG(o.total_amount), 2) AS avg_order_value,
ROUND(100 * AVG(IF(o.status = 'returned', 1, 0)), 2) AS return_rate,
ROUND(100 * COUNT(DISTINCT IF(fo.first_date < CAST(o.order_date AS DATE),
o.customer_id, NULL))
/ COUNT(DISTINCT o.customer_id), 2) AS returning_customers
FROM orders o
JOIN first_order fo ON o.customer_id = fo.customer_id
GROUP BY CAST(o.order_date AS DATE)
),
web AS ( -- KPIs derived from the funnel
SELECT date,
sessions,
ROUND(100 * with_purchase / sessions, 2) AS conversion_rate,
ROUND(100 * (1 - with_purchase / with_cart), 2) AS cart_abandonment
FROM funnel
)
SELECT s.date, w.sessions, w.conversion_rate, w.cart_abandonment,
s.orders, s.revenue, s.avg_order_value, s.return_rate, s.returning_customers
FROM sales s
JOIN web w ON s.date = w.date
ORDER BY s.date
""")
target = str(LAKE / "gold" / "daily_kpis")
kpis.coalesce(1).write.mode("overwrite").parquet(target)
result = spark.read.parquet(target)
print("Days with KPIs:", result.count())
result.orderBy("date").show(5)
spark.stop()The query uses common table expressions (the WITH clauses), which give names to intermediate results and let you read the SQL step by step:
first_ordercalculates the date of each customer's first purchase; it is needed to know who is a returning customer.salesgroups the orders by day.IF(condition, a, b)lets you sum or average only the rows you are interested in:AVG(IF(status = 'returned', 1, 0))is the proportion of returned orders.COUNT(DISTINCT IF(...))counts the customers whose first purchase was before that day (IFreturnsNULLfor the others, andCOUNTignores nulls).webderives the two rates from the funnel. It reusesgold/daily_funnelinstead of recalculating it from the events: that way the dashboard's conversion will, by construction, be the same as the funnel's.- The final
JOINjoins the two halves by date. Because it is an inner join, the table contains only the days present in both sources: June 2026. The incomplete day of 1 July is left out, because it has no orders. - The write recalculates the whole table with
overwrite. With one row per day it is the simplest option and it is idempotent (lesson 03-06); on the real platform, it would be one more task in thenovamarket_dailyDAG, afterload_eventsandrebuild_amounts.
Days with KPIs: 30 +----------+--------+---------------+----------------+------+---------+---------------+-----------+-------------------+ | date|sessions|conversion_rate|cart_abandonment|orders| revenue|avg_order_value|return_rate|returning_customers| +----------+--------+---------------+----------------+------+---------+---------------+-----------+-------------------+ |2026-06-01| 1051| 13.23| 72.26| 100|161917.03| 1686.69| 7.0| 100.0| |2026-06-02| 1040| 11.54| 75.41| 111| 179343.0| 1701.26| 4.5| 100.0| |2026-06-03| 1059| 10.29| 78.59| 113|187331.16| 1742.39| 7.08| 100.0| |2026-06-04| 1032| 13.57| 73.33| 112| 158254.4| 1557.5| 5.36| 100.0| |2026-06-05| 1065| 12.49| 73.87| 110|165865.01| 1591.26| 4.55| 100.0| +----------+--------+---------------+----------------+------+---------+---------------+-----------+-------------------+ only showing top 5 rows
For June as a whole: 30,943 sessions, a conversion rate of 12.07%, cart abandonment of 74.5%, 3,226 orders, €5.12 million in net revenue, an average order value of €1,677 and a return rate of 5.3%.
Two observations about what the table shows:
returning_customersis 100% every day. In the practice data, all 1,000 customers buy several times a month, so in June none of them is new. An indicator that never moves tells you nothing: on a real dashboard it would be withdrawn, or replaced with one that does discriminate (in a real shop, this figure is usually a long way from 100%).- The return rate for the last few days is provisional. An order placed yesterday has not yet had time to be returned. With real data, the rate for recent days always looks better than it will end up being.
Take care when summarising rates
To obtain the month's average order value from the daily table, the temptation is to average the column. That is a mistake: rates and averages are not averaged; they are recalculated from their numerators and denominators.
SELECT ROUND(AVG(avg_order_value), 2) AS mean_of_means, -- 1677.22: wrong
ROUND(SUM(avg_order_value * orders) / SUM(orders), 2) AS month_aov -- 1677.12: right
FROM daily_kpisHere the difference is ten cents, because every day has a similar volume. With very uneven days (a Black Friday next to an ordinary Tuesday), the mean of means can be several points out. That is why KPI tables also store the components (sessions, orders), not just the ratios.
A single definition: the semantic layer
Picture Monday's meeting. Marc's dashboard says that June's conversion was 12.1%. Marketing's says it was 22.7%. A product report talks about 26.2 purchases per 100 sessions. Nobody has made a calculation error:
| Who | What they calculate | Result |
|---|---|---|
| Marc | Sessions with a view, a cart and a purchase / sessions | 12.1% |
| Marketing | Sessions with at least one purchase event / sessions (6,982 out of 30,759) | 22.7% |
| Product | Purchase events / sessions (8,070 out of 30,759) | 26.2% |
Three figures with the same name. The rest of the meeting is spent arguing about which is "the right one", and the consequence is worse than the time lost: management stops trusting the data.
The remedy is for each metric to have a single definition, written in a single place, which every dashboard draws on. There are two ways of achieving this, and they are compatible with each other:
- Gold metric tables. This is what you have just done: conversion is calculated once, in
compute_kpis.py, and every dashboard readsgold/daily_kpis. Simple and effective; its limit is that each new breakdown (by device, by province) requires extending the table. - Semantic layer. This is a component sitting between the data and the consumption tools, where metrics are declared (their formula, their dimensions, their filters) and which generates the appropriate SQL for each query. That way, "conversion rate by device and week" is always calculated with the same logic, whether it is requested by a dashboard, a notebook or an application. Tools that offer this function include dbt's semantic layer, Looker's modelling (LookML), Cube and the metrics built into the catalogues of some lakehouse platforms.
In both cases, the underlying rule is organisational: formulas are not written inside dashboards. A dashboard that calculates its own conversion is the origin of Monday's meeting. Who approves a definition and how it is documented is part of data governance, which is covered in lesson 05-02.
Dashboard design
A dashboard is a screen that brings together the indicators needed to monitor an activity. The charts are built with the principles from lesson 04-04; here the question is what to put on it and how to arrange it.
First, the audience
| Level | Who uses it | What they need | Freshness | Example at NovaMarket |
|---|---|---|---|---|
| Operational | Those who carry out the work: warehouse, customer service, fraud team | What is happening now and what needs attention | Minutes or seconds | Orders awaiting dispatch; fraud alerts |
| Tactical | Area managers and analysts | How the week or the month is going, and why | Daily | Funnel by device; sales by category |
| Strategic | Senior management | Whether the objectives are being met | Daily or weekly | The main KPIs against target |
Mixing audiences is the most common design failure: a dashboard that tries to serve both the warehouse and senior management at once serves neither.
Visual hierarchy: from overview to detail
People read a screen from top to bottom and from left to right, and spend a few seconds deciding whether there is anything to look at. The design must go along with that path:
- At the top, the key figures: four to six KPIs in large type, each with its comparison (against target or the previous period) and a status signal.
- In the middle, the trends: how the main indicators are evolving.
- At the bottom, the breakdowns: by category, channel, device or segment, to explain the why.
- Separately, the detail: filters and links to more specific dashboards. This is the principle of overview first, details on demand.
A number on its own means nothing. "Conversion: 12.1%" does not say whether it is good or bad; "12.1%, target 12.5%" does. Every KPI is shown with a point of comparison.
Data freshness
Every dashboard must state how recent its data is. The freshness needed depends on the decision: the fraud team needs seconds, which is why it is fed by stream processing (lesson 03-05); senior management makes decisions on trends, and the overnight load is enough for it. Demanding real time for an indicator that is reviewed once a week multiplies the cost without improving any decision.
Irene's dashboard
Irene belongs to the strategic level. Her dashboard, fed by gold/daily_kpis and the other gold tables, would look like this:
┌──────────────────────────────────────────────────────────────────────────────────────┐ │ NOVAMARKET · Executive summary · June 2026 Data up to: 2026-06-30 (06:00 load) │ ├──────────────────┬──────────────────┬──────────────────┬──────────────────┬──────────┤ │ NET REVENUE │ ORDERS / DAY │ CONVERSION │ AVG ORDER VALUE │ RETURNS │ │ €5.12M │ 107.5 │ 12.1% │ €1,677 │ 5.3% │ │ │ ▼ −4% vs May │ ▼ target 12.5% │ │ ● < 6% │ ├──────────────────┴──────────────────┴────────┬─────────┴──────────────────┴──────────┤ │ DAILY REVENUE (line + 7-day average) │ FUNNEL FOR THE MONTH │ │ │ Sessions ......... 30,943 100% │ │ (stable, at around €171,000 a day) │ With view ........ 29,822 96% │ │ │ With cart ........ 14,667 47% │ │ │ With purchase .... 3,735 12% │ ├──────────────────────────────────────────────┼───────────────────────────────────────┤ │ SALES BY CATEGORY (sorted bars) │ CUSTOMER SEGMENTS │ │ Television ████████████████ │ Best customers ............ 407 │ │ Computing █████████ │ Moderate spend ............ 456 │ │ Phones ████████ │ At risk of churning ....... 137 ◄ │ │ ... │ │ └──────────────────────────────────────────────┴───────────────────────────────────────┘ Filters: period · channel · device Definitions: link to the cards
Five figures at the top, each with its reference; two context charts; two breakdowns; the date of the data clearly visible; and a link to the definition cards. It fits on one screen and can be read in a minute. The sales by category come from gold/fact_sales and the segments from gold/customer_segments (lesson 04-03).
Cohort analysis
Aggregated KPIs hide a decisive question: do customers come back? A shop can keep its revenue up by constantly acquiring new customers while losing its old ones, and a total will not give it away.
A cohort is a group of customers who share a starting point, usually the month they signed up or made their first purchase. Cohort analysis follows each group over time and measures what share remains active: retention.
spark.read.parquet(str(LAKE / "silver" / "orders_complete")).createOrReplaceTempView("orders")
cohorts = spark.sql("""
WITH activity AS ( -- months in which each customer has bought
SELECT DISTINCT customer_id, MONTH(order_date) AS month
FROM orders
),
cohort AS ( -- month of each customer's first order
SELECT customer_id, MIN(month) AS cohort_month
FROM activity
GROUP BY customer_id
)
SELECT c.cohort_month,
a.month - c.cohort_month AS months_after,
COUNT(*) AS active_customers
FROM activity a
JOIN cohort c ON a.customer_id = c.customer_id
GROUP BY c.cohort_month, a.month - c.cohort_month
""")
(cohorts.groupBy("cohort_month").pivot("months_after").sum("active_customers")
.orderBy("cohort_month").show())activity has one row per customer and month with a purchase; cohort assigns each customer the month of their first order; the join counts how many customers in each cohort are still buying 0, 1, 2... months later. pivot (lesson 03-03) presents it as a matrix. (Using MONTH is enough because all the data is from 2026; with several years you would use year and month.)
+------------+---+---+---+---+----+----+ |cohort_month| 0| 1| 2| 3| 4| 5| +------------+---+---+---+---+----+----+ | 1|967|927|937|930| 934| 928| | 2| 32| 30| 31| 32| 29|NULL| | 3| 1| 1| 1| 1|NULL|NULL| +------------+---+---+---+---+----+----+
Each row is a cohort and each column the months elapsed. Of the 967 customers whose first purchase was in January, 927 bought again in February (96%) and 928 were still active in June. The NULL values are months that have not yet happened for that cohort.
A retention of 96% month after month is, once again, the hallmark of synthetic data. What matters is knowing how to read the table you will come across with real data, which looks very different (illustrative figures, as a percentage of each cohort's initial size):
| Cohort | Month 0 | Month 1 | Month 2 | Month 3 | Month 4 |
|---|---|---|---|---|---|
| January | 100% | 31% | 24% | 21% | 20% |
| February | 100% | 33% | 26% | 23% | |
| March (discount campaign) | 100% | 19% | 13% | ||
| April | 100% | 34% |
It is read in three directions. Horizontally, each cohort's curve: it drops sharply in the first month and then levels off. Vertically, cohorts are compared at the same age: March's retains much worse, a sign that the discount campaign attracted one-off buyers. Diagonally lies each calendar month. That vertical reading is the one an aggregated KPI would never show: March would simply have been "a good month for acquisition".
A/B tests
A KPI tells you what has happened; it does not tell you why. If conversion rises in the week the purchase button was redesigned, was it because of the button, a campaign that happened at the same time, or chance? The most reliable way of finding out is a controlled experiment: an A/B test.
- Hypothesis. It is formulated before starting, with its metric: "the new button will increase the conversion rate".
- Two random groups. Visitors are split at random: the control group (A) sees the current version and the treatment group (B) the new one. Randomness ensures that the two groups are equivalent in every other respect, so any difference is due to the change... or to luck.
- Size and duration, fixed in advance. You calculate how many sessions are needed to detect the expected improvement.
- Analysis at the end. The metric is compared and you check whether the difference is statistically significant.
How much difference chance produces
Before trusting an A/B test, it is worth seeing what differences appear when there is no change at all. This is what is called an A/A test. June's sessions are split into two groups according to a hash of their identifier, which is equivalent to a random draw, and both halves get exactly the same shop:
spark.read.parquet(str(LAKE / "silver" / "web_events")).createOrReplaceTempView("events")
spark.sql("""
CREATE OR REPLACE TEMP VIEW sessions AS
SELECT session_id,
MIN(date) AS start_date,
MAX(IF(event_type = 'product_view', 1, 0))
* MAX(IF(event_type = 'add_to_cart', 1, 0))
* MAX(IF(event_type = 'purchase', 1, 0)) AS converts
FROM events
GROUP BY session_id
""")
ab_query = """
SELECT IF(pmod(hash(session_id), 2) = 0, 'A', 'B') AS ab_group,
COUNT(*) AS sessions,
SUM(converts) AS conversions,
ROUND(100 * AVG(converts), 2) AS conversion_rate
FROM sessions
WHERE start_date <= '{until}'
GROUP BY 1
ORDER BY 1
"""
for until in ("2026-06-03", "2026-06-14", "2026-06-30"):
print("Data accumulated up to", until)
spark.sql(ab_query.format(until=until)).show()hash(session_id) turns the identifier into a random-looking number and pmod(..., 2) keeps its remainder when divided by 2: each session always falls into the same group, as an experiment requires. The result, in summary:
| Data accumulated up to | Sessions (A / B) | Conversion A | Conversion B | Relative difference |
|---|---|---|---|---|
| 3 June | 1,559 / 1,580 | 10.84% | 12.78% | B wins by 18% |
| 14 June | 7,160 / 7,178 | 11.80% | 12.80% | B wins by 8% |
| 30 June | 15,388 / 15,371 | 12.00% | 12.40% | B wins by 3% |
There was no treatment at all, and yet on the third day "B" seemed 18% better. If, on day 3, someone had looked at the dashboard of a real experiment with these figures, they would have announced a resounding success. By the end of the month, the advantage has shrunk to 3%.
Statistical significance, without heavy formulas
Statistical significance answers this question: if A and B were in fact the same, how likely would I be to see, by pure chance, a difference at least as large as this one? That probability is called the p-value. By convention, if it is below 5% (0.05) the difference is considered significant: it would be unusual for chance alone to produce it.
This function calculates it for two conversion rates. You do not need to memorise the formula; you do need to understand what goes in and what comes out:
from math import erfc, sqrt
def p_value(conv_a, n_a, conv_b, n_b):
"""Probability of seeing a difference like this (or larger) if A and B were the same."""
p_a, p_b = conv_a / n_a, conv_b / n_b
p = (conv_a + conv_b) / (n_a + n_b) # pooled rate
error = sqrt(p * (1 - p) * (1 / n_a + 1 / n_b)) # variation expected by chance
z = abs(p_b - p_a) / error # difference measured in "errors"
return erfc(z / sqrt(2))
print(round(p_value(1847, 15388, 1906, 15371), 3)) # full month: 0.287
print(round(p_value(169, 1559, 202, 1580), 3)) # up to day 3: 0.092With the full month, the p-value is 0.287: a difference like the one observed would appear by chance almost three times in ten. It is not significant, which is the correct conclusion, because there was no real difference. The function also shows what significance depends on: the magnitude of the difference and the size of the groups. With few sessions, chance produces large differences.
Typical mistakes
- Looking too early and stopping when B is winning (peeking). This is the most frequent mistake and the one you have just seen. Every glance is a new opportunity for chance to cross the threshold; anyone who looks daily and stops on the first "significant" day will end up declaring winners that are not. The duration is set in advance and respected.
- Small samples. Reliably detecting a rise in conversion from 12% to 13% requires some 17,000 sessions per group: more than all of June's traffic in the practice data. The smaller the improvement you are looking for, the more data you need.
- Durations that do not cover complete cycles. A test lasting three working days tells you nothing about the weekend. Whole weeks are used.
- Testing many metrics and keeping the one that comes out. With twenty metrics, one will turn out "significant" by chance. The primary metric is decided beforehand.
- Confusing significant with important. With millions of sessions, a 0.1% improvement can be significant and still not justify the cost of the change.
- Non-random allocation. Sending the new version only to app users, or only in the mornings, compares groups that were already different.
From the figure to action: communicating a finding
Analysis ends when someone decides something. And that depends, more than it might seem, on how it is told. A well-communicated finding follows this order:
- The conclusion first. The audience does not want the story of the investigation, but its result. Everything else is support.
- The minimum sufficient evidence. One or two figures and a chart, with their point of comparison.
- The consequence (so what?). What it means for the business, in euros or in customers.
- The recommendation. A specific action, with an owner and, if possible, a way of measuring whether it works.
- The limits. How much confidence it deserves and what is not known.
Compare two ways of telling the same result from lesson 04-03:
Version that leads nowhere: "We applied K-Means with k = 3 to the standardised RFM variables and obtained a silhouette of 0.56. Cluster 0 has an average recency of 31.1."
Version that leads to a decision: "137 customers, who have bought €3.9 million worth from us this half-year, have not bought anything for a month, when the typical customer buys every week. We propose a reactivation campaign aimed at them alone, measured with an A/B test: half receive the offer and the other half do not. The list is in
gold/customer_segments. Limitation: the segmentation is based on six months of data."
The second does not mention the algorithm. It says how many, how much, what to do, how you will know whether it works and how far the evidence goes. And you also need to know how to communicate an uncomfortable result: the purchase classifier from lesson 04-03 can be summed up as "with the current data we cannot predict which sessions will buy; to try, we would need to record X", which is a conclusion just as useful as a model that works.
Common Mistakes and Tips
- Calling everything a KPI. If there are more than ten or so "key" indicators, you need to choose.
- Defining the KPI verbally. Without a written card, each team will end up calculating its own version.
- Calculating the metrics inside each dashboard. It guarantees contradictory figures. One definition, one place.
- Averaging rates. Rates are recalculated from the numerator and the denominator.
- Showing figures without a comparison. A number with no target or previous period says nothing.
- Optimising an indicator with no counterweight. It will end up improving at the expense of something nobody is watching.
- Designing a dashboard for every audience. One audience, one dashboard.
- Demanding real time by default. Freshness is chosen according to the decision, and it has a cost.
- Taking recent days as final. Returns, payments and late loads change them.
- Stopping an A/B test as soon as it is winning. Set the duration before you start.
- Presenting the method instead of the conclusion. The decision-maker cares about what to do, not which algorithm you used.
- Tip: review dashboards from time to time and remove whatever nobody looks at. A dashboard that only ever grows ends up as noise.
Exercises
Exercise 1: a KPI card
Write the definition card for NovaMarket's cart abandonment KPI, with the six elements (objective, formula, grain, source, owner and threshold) and at least one note. Also state which other indicator you would pair it with as a counterweight.
Exercise 2: a new KPI
Marketing wants to track the percentage of orders placed through the app. Calculate it by day with Spark SQL for June from silver/orders_complete, explain how you would add it to gold/daily_kpis and correctly calculate the value for the full month.
Exercise 3: interpreting an A/B test
NovaMarket tests a simplified checkout process for four full weeks, with the sample size calculated in advance. Result: group A, 17,200 sessions and 2,064 conversions; group B, 17,150 sessions and 2,247 conversions. Calculate the rates and the p-value with the function from the lesson. What would you recommend? What would you check before accepting it?
Solutions
Exercise 1
KPI: Cart abandonment
------------------------------------------------------------------------------
Objective Detect friction in the final stretch of the purchase (payment, delivery).
Decisions: prioritise improvements to checkout; reminders.
Formula (sessions with a cart − sessions that complete the purchase)
/ sessions with a cart x 100
Grain Daily. Can be broken down by device.
Source gold/daily_funnel (columns with_cart and with_purchase)
Owner Business: checkout product manager.
Calculation: data team.
Threshold Target: below 72%. Alert: above 78%.
Notes Only a purchase within the same session counts: someone who adds
today and buys tomorrow is recorded as an abandonment.Counterweight: the return rate or the average order value. An "easier" checkout that reduces abandonment at the cost of more impulse purchases that get returned, or of smaller orders, is not an improvement. June's value is 74.5%, high but normal: in real e-commerce, cart abandonment is usually around 70%.
Exercise 2
spark.sql("""
SELECT CAST(order_date AS DATE) AS date,
COUNT(*) AS orders,
SUM(IF(channel = 'app', 1, 0)) AS app_orders,
ROUND(100 * AVG(IF(channel = 'app', 1, 0)), 2) AS pct_app_orders
FROM orders
WHERE order_date >= '2026-06-01'
GROUP BY CAST(order_date AS DATE)
ORDER BY date
""").show(3)+----------+------+----------+--------------+ | date|orders|app_orders|pct_app_orders| +----------+------+----------+--------------+ |2026-06-01| 100| 41| 41.0| |2026-06-02| 111| 43| 38.74| |2026-06-03| 113| 35| 30.97| +----------+------+----------+--------------+ only showing top 3 rows
To add it to the table, the columns app_orders and pct_app_orders are added to the sales expression in compute_kpis.py and included in the final SELECT; when the script is run again, the whole table is regenerated. It is worth storing app_orders, the numerator, as well, and not just the percentage: the month's value is calculated as 100 * SUM(app_orders) / SUM(orders), never as the average of the daily percentages. For June it gives 38.96% (1,257 out of 3,226 orders), in line with the 39.9% for the half-year (lesson 04-02). Notice how much the daily value fluctuates, between 27% and 47%: with around a hundred orders a day, the daily indicator is almost all noise, and it makes more sense to track it by week.
Before adding it to the executive dashboard, put it through the lesson's test: would we do anything differently if it changed? If the answer is that the company wants to move customers to the app because they buy again more often there, it is actionable; if nobody knows what they would do with it, it is a metric for a tactical marketing dashboard, not a KPI.
Exercise 3
print(2064 / 17200, 2247 / 17150) # 0.12 and 0.131
print(round(p_value(2064, 17200, 2247, 17150), 4)) # 0.0021Conversion goes from 12.0% to 13.1%: 1.1 points, a relative improvement of 9%. The p-value is 0.002: if the two checkout processes were the same, a difference like this would appear by chance twice in a thousand times. It is statistically significant, and the test was done properly: duration fixed in advance, full weeks and sufficient size. The recommendation is to roll out the new checkout process; according to the metric tree, one point of conversion is worth about €450,000 gross a month.
Before accepting it:
- The counterweights: check that neither the average order value nor, after a few weeks, the return rate has worsened.
- The allocation: check that the two groups have a similar mix of devices and anonymous visitors, a sign that the assignment really was random.
- The breakdowns, with caution: check that the improvement does not come from a single segment while another gets worse; but without searching through twenty breakdowns for one that "comes out".
- The follow-up: monitor conversion after the rollout. The effect of a novelty sometimes fades.
Conclusion
A piece of data is a fact; a metric, a calculated measure; a KPI, a metric chosen because it measures progress towards an objective. A good KPI is defined in writing, with an objective, formula, grain, source, owner and threshold, comes with a counterweight and is actionable, not a vanity metric. Indicators are organised into a metric tree (revenue = sessions × conversion × average order value) that makes it possible to diagnose and quantify. You have calculated NovaMarket's with Spark SQL and materialised them in gold/daily_kpis, seen why each metric must have a single definition and designed Irene's dashboard with her audience, visual hierarchy and data freshness in mind. Cohort analysis has shown you what a total hides, A/B tests how to tell a real improvement from chance (and why you must not look too early), and you have learnt to tell a finding by starting with the conclusion.
This lesson brings Module 4 to an end. You started by drawing the map of analysis tools and adopting the rule that has underpinned everything: aggregate big, analyse small. You carried out the exploratory analysis of the orders and events, and discovered their strengths and their limits. You trained machine learning models with Spark MLlib and learnt to distrust results that are too good. You turned aggregates into clear, honest charts. And you have just completed the full journey, from data to decision: NovaMarket's lake does not just store and process, it answers Irene's question with gold/customer_segments, gold/daily_kpis and a dashboard that can be read in a minute.
Over four modules you have been accumulating, lesson by lesson, separate rules: idempotent processes, explicit schemas, one definition per metric, validating before trusting. The time has come to put them in order and see how they apply beyond NovaMarket. In Module 5, Practices and Case Studies, you will move from techniques to craft: how to work well, how quality is guaranteed, what it costs and how organisations in different industries have solved it. The first lesson, Best Practices in Big Data, brings together in one place the design, development and operation principles that distinguish a reliable data platform from one that works by chance.
