KPI list
This is the canonical reference for every KPI computed by P2Lab Stats. The same metrics appear in the in-module reports and in the KPI widgets above the order and customer list.
Each entry lists:
- Definition — what the metric counts
- Formula — how it’s computed
- Where used — which report / widget surfaces it
All metrics support previous-period comparison (Δ %) calculated against an equal-length range ending immediately before the current range.
Order KPIs
Section titled “Order KPIs”Available in the Order KPI widget and the Sales reports.
Orders
Section titled “Orders”- Definition — count of orders placed in the range.
- Formula —
COUNT(*)over orders whoseorderDateTimefalls in the range and whosestateMachineStateis in the active filter. - Where used — every sales report, order KPI widget.
Items ordered
Section titled “Items ordered”- Definition — total line-item quantity in the range.
- Formula —
SUM(lineItem.quantity)over orders in the range. - Where used — Sales summary, order KPI widget.
Orders done
Section titled “Orders done”- Definition — count of orders that reached the “completed” / “done” state in the range.
- Formula —
COUNT(*)over orders with state machine history showing a transition to done within the range. - Where used — order KPI widget.
Orders done in time
Section titled “Orders done in time”- Definition — orders that reached done within the configured SLA window from the order date.
- Formula —
COUNT(*)over orders where(doneAt - orderDateTime) <= sla_window. - Where used — order KPI widget.
Revenue
Section titled “Revenue”- Definition — total monetary value of orders in the range.
- Formula —
SUM(amountTotal)(oramountNet, configurable) over orders in the range. - Where used — every sales report, order KPI widget.
- Definition — average order value.
- Formula —
revenue / orders. - Where used — every sales report, order KPI widget.
Cancelled orders
Section titled “Cancelled orders”- Definition — count of orders that reached the cancelled state in the range.
- Formula —
COUNT(*)over orders with a transition to cancelled in the range. - Where used — Sales → Cancelled, order KPI widget.
Refunded orders
Section titled “Refunded orders”- Definition — orders with a refund transaction in the range.
- Formula —
COUNT(DISTINCT orderId)over refund transactions in the range. - Where used — order KPI widget.
Customer KPIs
Section titled “Customer KPIs”Available in the Customer KPI widget and the Customer reports.
New customers
Section titled “New customers”- Definition — customers whose first order falls in the range.
- Formula —
COUNT(DISTINCT customerId)where the customer’s earliest order is in the range. - Note — counts on first-order date, not registration date.
- Where used — Customer overview, customer KPI widget.
Returning customers
Section titled “Returning customers”- Definition — customers who had at least one order before the range and at least one order in the range.
- Formula —
COUNT(DISTINCT customerId)with(min_order_date < range_start) AND (any order in range). - Where used — Customer overview, customer KPI widget.
Active customers
Section titled “Active customers”- Definition — customers who placed at least one order in the range.
- Formula —
COUNT(DISTINCT customerId)over orders in the range. - Where used — Customer overview, customer KPI widget, cohort matrix.
Orders per customer
Section titled “Orders per customer”- Definition — average number of orders each active customer placed in the range.
- Formula —
orders / active_customers. - Where used — Customer overview, customer KPI widget.
Average customer revenue
Section titled “Average customer revenue”- Definition — average revenue per active customer.
- Formula —
revenue / active_customers. - Where used — Customer overview, customer KPI widget.
Guest orders
Section titled “Guest orders”- Definition — orders without a registered customer account.
- Formula —
COUNT(*)over orders whereorderCustomer.customerId IS NULL. - Where used — Customer overview, customer KPI widget.
Retention rate
Section titled “Retention rate”- Definition — share of previous-period customers who also ordered in the current period.
- Formula —
customers_in_both_periods / customers_in_previous_period. - Where used — Customer overview, customer KPI widget.
Registration conversion rate
Section titled “Registration conversion rate”- Definition — share of guest orders that resulted in a registered customer account.
- Formula —
guest_orders_converted / total_guest_orders. - Where used — Customer overview, customer KPI widget.
Stock KPIs
Section titled “Stock KPIs”Used across the Stock reports.
Total units in stock
Section titled “Total units in stock”SUM(product.stock) across the catalogue (excluding deactivated products by default).
In-stock products / Out-of-stock products
Section titled “In-stock products / Out-of-stock products”COUNT(*) WHERE stock > 0 and its complement.
Stock value
Section titled “Stock value”SUM(stock × purchasePrice) — switchable to stock × price (selling) under the report’s view options.
Low-stock count
Section titled “Low-stock count”COUNT(*) WHERE stock <= low_stock_threshold.
Days of supply
Section titled “Days of supply”Per product: current_stock / (units_sold_in_range / days_in_range). Used as the basis for Overstock and Depletion risk.
Margin KPIs
Section titled “Margin KPIs”Used in the Margins report.
Total margin
Section titled “Total margin”SUM(revenue - cogs) over orders in the range, where cogs = SUM(lineItem.quantity × purchase_price_at_order_time).
Average margin %
Section titled “Average margin %”total_margin / revenue × 100, weighted by revenue.
Low-margin products count
Section titled “Low-margin products count”COUNT(*) WHERE product_margin_pct < threshold.
Deteriorating products count
Section titled “Deteriorating products count”COUNT(*) WHERE current_period_margin_pct < previous_period_margin_pct.