How to track On-Time Delivery using SQL

How to implement on time delivery metrics in your business, and why they are key to customer satisfaction.

Why are On-Time Delivery metrics so important?

When customers' orders are not delivered on time, they may miss their delivery, or it may arrive too late to be useful.

Ensuring a high on-time delivery rate protects customer satisfaction, so it's important to measure if customers are receiving their items on time.

Customer receiving a delivery
A flawless handover

Definition

On-Time Delivery (OTD), sometimes called On-Time Performance, or On-Time Percentage (OTP) measures the percentage of orders that are delivered on time:

On-Time Delivery %=Number of On-Time DeliveriesTotal Deliveries×100On\text{-} Time \ Delivery \ \% = {Number \ of \ On\text{-} Time \ Deliveries \over Total \ Deliveries} \times 100

Calculating On-Time Delivery

In order to calculate the OTD %, we need to know when the deliveries were meant to be delivered, and when they were actually delivered.

Assuming we are starting with the below data from 100,000 deliveries, which is stored in a database. For each order delivery_slot_start and delivery_slot_end mark the time period when the delivery was expected, and delivery_time is when the delivery was actually made.

Order ID Delivery Slot Start Delivery Slot End Delivery Time
12021-08-102021-08-102021-08-10
22020-04-042020-04-042020-04-04
32021-12-172021-12-172021-12-17
42021-11-032021-11-032021-11-03
52021-01-232021-01-232021-01-23
62021-07-012021-07-012021-07-01
72019-01-082019-01-082019-01-08
82020-06-062020-06-062020-06-06
92020-12-152020-12-152020-12-15
102019-11-032019-11-032019-11-03
No Results

We first compare the delivery time to the start and end of the delivery slot to determine if the order was delivered on time, early, or late.

Order ID Delivery Slot Start Delivery Slot End Delivery Time Delivery Status
12021-08-102021-08-102021-08-10On-Time
22020-04-042020-04-042020-04-04Early
32021-12-172021-12-172021-12-17On-Time
42021-11-032021-11-032021-11-03On-Time
52021-01-232021-01-232021-01-23On-Time
62021-07-012021-07-012021-07-01On-Time
72019-01-082019-01-082019-01-08On-Time
82020-06-062020-06-062020-06-06Late
92020-12-152020-12-152020-12-15On-Time
102019-11-032019-11-032019-11-03On-Time
No Results

From here, we can calculate the OTD % for each month in the dataset.

Delivery Mon Total Deliveries on Time Early Late
2019-01-012,23562%32%7%
2019-02-011,76164%29%7%
2019-03-012,27564%30%6%
2019-04-011,83862%31%7%
2019-05-012,39861%32%7%
2019-06-012,20463%30%7%
2019-07-012,57661%32%7%
2019-08-011,97162%31%6%
2019-09-012,04464%30%6%
2019-10-012,66561%32%7%
No Results

Presenting On-Time Delivery Metrics

On-time delivery metrics are typically presented as a time series, allowing the viewer to see the OTD % for each month.

We can use Evidence to plot a line chart to see how the OTD % changes over time:

We can also use an area chart to help show the proportion of deliveries that were late or early: