Which stores are slipping?

The claim

Of the 53 Casey’s stores in the bottom tenth for the first half of 2025, 8 were still there in the second half. Luck alone would keep about 5.

Why I built it

Most analysis is two jobs. First you get a messy file into a state you can trust. Then you ask whether a pattern is real. I wanted to show both on public data, in the order they happen. I used to build the weekly store report for a retail chain, so I picked the question a chain manager asks.

The page lets you switch chains, open the SQL behind any chart and write your own queries against the same database.

What I built

A six-chapter page on Iowa’s public store orders for 2024 and 2025, 6,075,403 published rows. Node scripts clean the file in SQL and sum it to one row per store, month and family of drink. The page loads that 5.7 MB database into SQLite in the browser and runs each chart’s query live. AI coding agents (Claude Code) wrote the code under my direction.

Scatter chart of Casey's stores. Across is each store's change in the first half of 2025, up is its change in the second half, each against the same half of 2024. The dots form a round cloud around zero. Eight orange dots sit in the shaded bottom-left corner, the stores in the bottom tenth both times. Scatter chart of Casey's stores. Across is each store's change in the first half of 2025, up is its change in the second half, each against the same half of 2024. The dots form a round cloud around zero. Eight orange dots sit in the shaded bottom-left corner, the stores in the bottom tenth both times.
Each dot is a Casey's store. A store's first half says little about its second.

Decisions

  • SQLite in the browser. DuckDB’s browser package is 149 MB. sql.js is 0.66 MB, and Node runs the same dialect.
  • The page runs the SQL it shows. Each chart’s query is a file, imported as text and run as written.
  • Stay-at-the-bottom counts instead of a correlation. A count beside what chance would give reads faster than a coefficient.
  • Only stores open all eight quarters under one number. That keeps 1,760 of 2,353. Joining renumbered stores by address would need a judgement on each one.

How I tested it

A parity test runs all 11 page queries, for every chain, through Node’s SQLite and through sql.js, and requires identical rows. Other tests fail if rebuilt data stops supporting a sentence the page states in words, such as “mostly luck”. A rebuild from the raw files reproduced the shipped database byte for byte. I checked the page at 1280 and 390 pixels wide, in both themes, with the production security headers.

What broke

  • The file repeats whole rows. From October 2024, some orders appear up to four times. My first monthly totals made those months look like records. Removing exact copies took 2025’s fall from 8.3% to 5.0%.
  • The cost columns are blank for 18 of 24 months. I dropped margin rather than guess it.
  • The cleaning script also ran the next step’s SQL. A full rebuild caught it.

What next

Add 2026 when Iowa publishes it, and see whether the stores at the bottom in both halves stay there.