Field note · July 28, 2023

Five minutes with unit_price_usd in retail-orders

7,000 rows, 5,287 distinct values, and the one fact about unit_price_usd that changes how you query it.

1 min read ·Data quality ·quality practice

Someone asked what is in unit_price_usd on retail-orders, and the honest answer took one query.

7,000 rows, no nulls, 5,287 distinct values. List price per unit.

The five-number version: min 6.07, p10 18.42, median 48.86, p90 169.87, max 589.71. The mean is 72.66.

The p10 to p90 band — 18.42 to 169.87 — is where ordinary rows live, and it is the pair worth quoting when somebody asks what to expect. Min and max describe the two strangest rows in the table and nothing else; they are useful for spotting impossible values and misleading for everything else.

sql
select
  count(*)                         as rows,
  count(unit_price_usd)            as present,
  count(*) - count(unit_price_usd) as nulls,
  count(distinct unit_price_usd)   as distinct_values
from retail_orders;

The mean sits 49% above the median, which is the whole story: anything that reports the average of unit_price_usd is reporting a number most rows are below. Put the median next to it or drop the mean.

Where this bites: a filter like unit_price_usd > 72.66 reads as "above average" and selects a minority of rows — a smaller minority than the phrase suggests to whoever asked for it. If the request was "the typical ones", the threshold they meant was 48.86.

The grain is one row per order line, which is the context every one of those numbers depends on. None of them survive a change of grain, which is why "profile the column" and "profile the table" are the same job. Full schema, and the CSV, on the dataset page.