A dashboard is a family of data queries; each control changes the population and needs an explicit, inspectable state.
Dashboard filters and provenance: make every view reproducible
Version the query state
A screenshot of a 74 percent review rate means little without period, channel, eligibility version and data-refresh time. Encode those fields in a shareable state record. If a filter changes the cohort, recompute counts and intervals rather than carrying cached percentages across populations. The denominator must travel with every filtered value.
Manage defaults
A default “last 30 days” view moves each day. Use a fixed reporting cutoff for reproducible review packets and mark live periods provisional. If the dashboard initially excludes low-volume channels, disclose that exclusion rather than implying the total includes all channels. Make “all eligible channels” a testable state.
Prevent stale joins
A filter change may return fast chart data while the companion table or alternative text still shows the previous request. Apply response IDs or cancellation to keep all representations synchronized. The data pipeline should expose snapshot ID and query version. Publication boundaries offer a model for replacing a complete snapshot atomically.
Reproduce a decision
Save a review packet with filter state, metric definition, source snapshot, numerator, denominator and chart version. Re-run it after a late receipt arrives; the old packet must remain explainable even if the live dashboard changes. Test an invalid channel and a period with no eligible receipts rather than silently falling back to another state.
Implementation
def dashboard_state(snapshot_id, start_day, end_day, channels):
if not snapshot_id or start_day >= end_day:
raise ValueError("invalid snapshot or period")
selected = tuple(sorted(set(channels)))
if not selected:
raise ValueError("select at least one channel")
return {"snapshot_id": snapshot_id, "start_day": start_day,
"end_day": end_day, "channels": selected}Performance and operating cost
Canonicalizing C selected channels costs O(C log C) time and O(C) space. Query and render costs depend on the backend and mark count; a versioned aggregate cache can help, but its key must include every population-changing filter.
Common Mistakes
- Do not publish a decision screenshot without snapshot and filter state.
- Do not reuse an overall interval after changing the cohort.
- Do not let chart, table and alternative text resolve different query responses.
