Postman collection
KPIs Read

pixiReportShippingEfficiency

Returns the average order throughput time in days and the percentage of orders shipped within 24 hours for the last N days.

Calculates two shipping efficiency KPIs for the CEO dashboard. The values are returned as one row and also through the two OUTPUT parameters.

  1. Sampling window: The window starts at midnight of the day that lies @SamplingPeriod days before today and ends at the current time. If @SamplingPeriod is NULL, 7 days are used.
  2. Orders considered: An order counts as shipped if it has at least one order line with status AUS and a ShipDate inside the window, and none of its lines has a status other than AUS. Orders that are only partly shipped or that contain lines in any other status are ignored.
  3. Throughput time per order: For the shipped lines inside the window, the code reads the ANG and AUS entries from the order history. The throughput time of an order is the difference in hours (DATEDIFF(hh, …)) between the earliest ANG status change and the latest AUS status change.
  4. KPIs:
    • AVGThroughputTimeInDays: the sum of the per-order throughput times converted to days (hoursPassed / 24), divided by the number of shipped orders. The result is rounded to 2 decimals.
    • PercThroughputTimeIn24h: the number of orders with a throughput time of at most 24 hours, divided by the number of shipped orders and multiplied by 100. The result is rounded to 2 decimals.
  5. If no shipped orders are found, both values are 0.

Notes

  • All reads use NOLOCK, so the values can include uncommitted data.
  • hoursPassed is an integer, so hoursPassed / 24 is an integer division. Each order contributes only full days to the average, and fractions of a day are cut off. An order with 30 hours counts as 1 day, and an order with 20 hours counts as 0 days.
  • DATEDIFF(hh, …) counts hour boundaries that are crossed. It does not measure exact elapsed time.
  • The divisor is the number of all fully shipped orders. This also includes orders that have no ANG/AUS history entries. Such orders have no throughput time or a NULL throughput time. They lower both KPIs.
  • Edge case: if shipped orders exist but none has matching history entries, the sum is NULL. AVGThroughputTimeInDays is then returned as NULL and PercThroughputTimeIn24h as 0.
  • Only lines with a ShipDate inside the window are used to determine the earliest ANG and the latest AUS date.
  • The call can be expensive on large order histories, because orderhistory is scanned for all ANG/AUS entries.

Tables used

orderlines · Read orderheader · Read orderhistory · Read
SQL object:
dbo.pipiReportShippingEfficiency
Updated at 2026-10-30