Reporting has one job: to be believed. A dashboard that is fast, beautiful and occasionally wrong is worse than no dashboard, because the first time a manager finds two screens disagreeing about last month's revenue, they export both to a spreadsheet and never fully trust the product again. From then on, the reporting feature exists, but the real reporting happens in Excel.
This article is the reference our industry articles link to when they mention dashboards, owner statements or operational reports. Rather than walking through components, it walks through the specific ways reporting loses trust, and the design decision that prevents each one: inconsistent definitions, the wrong database, aggregation errors, time, staleness, permissions, exports and runaway queries.
Users forgive a slow report once. They do not forgive a wrong number, and they remember which screen showed it.
Two Screens, Two Numbers
The most common reporting failure is not a bug in any one query. It is two queries that are each correct for a slightly different definition. The sales dashboard counts revenue at signing, the finance report at invoicing; one excludes refunds, the other nets them; one uses the customer's time zone, the other the server's. Both are right, and the product looks broken.
The fix is to define each metric once, in one place, and make every chart, export and API read from that definition. A metric definition is more than a SQL expression:
| Field | Example | Why it has to be explicit |
|---|---|---|
| Name and description | Net revenue: invoiced amounts minus credits and refunds | The label on the chart must mean one thing everywhere |
| Source | Invoice lines and credit notes | Prevents one screen counting orders and another counting invoices |
| Grain | One row per invoice line | Determines what can be summed without double counting |
| Time attribute | Invoice date, not payment date | The most frequent cause of disagreeing totals |
| Time zone | The tenant's reporting time zone | Decides which day an event at 23:30 belongs to |
| Standard filters | Excludes test accounts and voided invoices | Hidden filters applied in one place only are invisible disagreements |
| Additivity | Fully additive | Tells the engine whether daily values can be summed into monthly ones |
| Owner | Finance | Someone decides when the definition changes |
Teams formalise this as a semantic layer. It can be a set of definitions in your own code, or tools built for the purpose such as Cube or the dbt semantic layer. The tool matters less than the rule: no chart may compute a metric that the semantic layer does not define.
The Production Database Is the Wrong Place to Ask Big Questions
Operational databases are tuned for many small reads and writes: load this order, update that shipment. Reports ask the opposite kind of question: scan a year of orders and group them six ways. Running those scans on the primary database slows down the product for everyone, usually during month-end, when both reports and transactions peak.
The path most products follow, in order of when each step becomes necessary:
| Stage | What it is | Fits when | Gives way when |
|---|---|---|---|
| Read replica | Reports query a replica of the operational database | Early; report queries are moderate and freshness of seconds is fine | Scans grow large enough that even the replica struggles, or replication lag shows up in reports |
| Rollup tables | Pre-aggregated tables in the same database, refreshed incrementally | Dashboards with known dimensions and stable questions | Users need ad-hoc slicing on dimensions nobody pre-aggregated |
| Columnar analytical store | ClickHouse, BigQuery, Snowflake or similar, fed from the operational data | Large event volumes, ad-hoc exploration, many dimensions | Rarely gives way; the cost is a pipeline to operate and data that is minutes behind |
PostgreSQL with a replica and well-designed rollups carries most B2B products a long way. The move to a columnar store is justified by scan volume and the need for ad-hoc analysis, not by the word "analytics" appearing on the roadmap. For text-heavy exploration and faceted counts, a search engine is another option; we compare that path in our Elasticsearch guide.
Sums, Averages and the Metrics That Refuse to Add Up
Rollups are where subtle arithmetic errors hide, because not every metric can be pre-computed at one grain and summed into another:
| Metric type | Example | Can daily rollups be summed into a month? | Store instead |
|---|---|---|---|
| Additive | Revenue, orders, hours logged | Yes | The daily sum |
| Ratio or average | Average order value, on-time rate | No: averaging daily averages weights a quiet day like a busy one | Numerator and denominator separately; divide at query time |
| Distinct count | Active users, unique customers | No: someone active on 20 days is counted 20 times | Recompute from detail, or store mergeable sketches such as HyperLogLog and accept a small, stated error |
| Snapshot | Open tickets, inventory on hand, account balance | No: summing daily balances is meaningless | The value at period end, or the average over the period, defined explicitly |
| Percentile | 95th-percentile response time | No | Histograms or quantile sketches that can be merged |
A dashboard that shows a monthly "average" computed by averaging thirty daily averages will disagree with the same metric computed from raw rows, and someone will find out. Record each metric's additivity in its definition, and let the query layer refuse to combine what cannot be combined.
Time Zones, Late Events and the Month That Changed After Close
Time is the second great source of disagreeing numbers. Store timestamps in UTC; bucket them in the reporting time zone that the metric definition names, usually the tenant's. A "day" in a tenant's time zone is sometimes 23 or 25 hours long around daylight-saving changes, and hourly charts should show that honestly rather than inventing or losing an hour.
Late-arriving data forces a decision about history. A refund processed on the 3rd for a sale made on the 28th of last month changes last month's net revenue. There are two legitimate answers, and the product has to offer the one each audience expects:
- As currently known. History is restated as corrections arrive. Operations teams usually want this.
- As reported at close. Closed periods are frozen as snapshots; corrections land in the current period. Finance usually needs this, because last month's figures have already been sent to someone.
The same question applies to dimensions. When a customer moves from the North region to the South, are last year's sales reported under North, where they happened, or South, where the customer is now? Keeping dimension history, often called a type 2 slowly changing dimension, lets reports answer either way. Without it, every reorganisation silently rewrites the past.
Freshness Is a Promise Printed on the Screen
Most reporting stacks are minutes or hours behind the operational data, and that is fine, as long as users know. The failure is a dashboard that looks live, isn't, and leads someone to act on a stale number.
- Show the data's age on every report, as "data as of 10:42", taken from the pipeline's last successful load, not from the page render time.
- Alert on lag, not just on failure. A pipeline that runs but falls further behind each hour is a failure that never raises an error.
- Separate operational views from analytical ones. "What is on the dock right now" belongs on a small, live query against operational data. "How did the dock perform this quarter" belongs on the analytical store. Forcing both through one path makes one of them wrong.
Some operational reports come almost free from good process design. If work items record every state transition with a timestamp, cycle time, time in each stage and SLA breaches are straightforward queries; our workflow engines reference explains why that transition log is worth having for this reason alone.
Permissions Follow the Data Into Every Chart
A reporting layer is a second way into all of a product's data, and it is often built with fewer checks than the first. The rules have to be the same ones the product enforces, applied at the query, not at the screen:
- Tenant isolation in the analytical store. Every row carries the tenant id, and the query layer adds the filter automatically. Row-level policies in the store itself (PostgreSQL row-level security, ClickHouse row policies, BigQuery row-level access policies) provide a second wall. How tenant routing works on the operational side is covered in our multi-tenant architecture article.
- Role scopes inside the tenant. A rep who can see only their own deals sees only their own deals in every chart, total and drill-down. The scope from the RBAC model becomes a query condition, never a filter applied after the numbers are computed.
- Small groups reveal individuals. An "average salary by team" chart for a team of one is that person's salary. For sensitive measures, suppress or merge groups below a minimum size.
- Drill-down re-checks access. A total someone may see does not mean they may see the rows inside it. Clicking through must apply the row-level rules again.
- Caches are keyed by permission. A cached result is valid only for users with the same tenant and the same effective scope.
Exports Are Reports That Leave the Building
Every reporting product eventually needs exports, and they are where good intentions go to break. A list of what export functionality has to handle:
- Run large exports asynchronously. Queue the job, stream rows to storage in chunks rather than building the file in memory, and notify the user when it is ready.
- Deliver through short-lived signed links, issued after a permission check, never through permanent public URLs.
- Neutralise formula injection. A cell value beginning with
=,+,-or@can be executed as a formula when the CSV is opened in a spreadsheet. Prefix such values so they are treated as text. - Make spreadsheets read the encoding correctly. A UTF-8 byte-order mark at the start of a CSV helps Excel display accented names correctly.
- Offer raw and formatted versions. Formatted exports match the screen; raw exports with stable column names and ISO dates are what people feed into other systems.
- Log every export: who, what, which filters, how many rows. An export is the easiest way for data to leave a product, and auditors know it.
- Schedule recurring reports through the notification system, with the same preferences, delivery tracking and access checks at send time. A scheduled report keeps arriving after its recipient leaves the company unless someone re-checks; our notification systems reference covers that pipeline.
Guardrails for Self-Serve Exploration
Custom report builders give users a way to write queries without writing SQL, which includes very expensive ones. One user grouping three years of events by day and by customer can occupy the analytical store for everyone. Guardrails keep exploration safe without removing it:
- statement timeouts and maximum date ranges on interactive queries, with longer ranges routed to asynchronous jobs;
- per-tenant concurrency limits, so one heavy user queues behind themselves rather than in front of everyone else;
- result caching keyed on the normalised query, the tenant and the permission version;
- a cost estimate before execution where the store provides one, with a warning above a threshold;
- a curated set of dimensions and metrics from the semantic layer, rather than raw tables, so exploration cannot bypass definitions.
Reconciling the Dashboard Against the Ledger
Trust is maintained by proving numbers, routinely and automatically, before users have to. Three habits do most of the work:
- Reconciliation checks. Every day, compare key totals in the reporting layer with the system of record: invoiced revenue against the billing ledger, shipment counts against the operational table. Alert when they diverge beyond a stated tolerance.
- Data tests on the pipeline. Uniqueness of keys, no nulls where nulls are impossible, accepted values for status fields, and row counts within expected ranges. dbt tests or the equivalent in your pipeline catch broken loads before a chart does.
- A path from every number to its rows. Any total should drill down to the records that produced it, subject to permissions. When a user doubts a number, being able to show them the rows usually settles it in a minute.
Owner statements in property management are a good example of reporting that has to reconcile to the cent, because it reflects money held for someone else; our property management guide shows the ledger such reports derive from.
What to Build First When Users Want Charts
A reporting capability is usually built under pressure from users who want charts. A sequence that gets them charts without creating the inconsistencies above:
- Write the metric definitions for the first ten metrics people actually ask for, including grain, time attribute and time zone.
- Serve the first reports from a read replica, through a query layer that applies tenant and role scope automatically.
- Add data-age labels and reconciliation checks before adding more charts.
- Build asynchronous exports with formula escaping and audit logging.
- Introduce rollups for the dashboards that are slow, with additivity respected.
- Move to a columnar store when scan volume or ad-hoc exploration demands it, keeping the same definitions on top.
- Open up self-serve exploration last, behind guardrails.
Charts are the visible part of reporting. Agreed definitions and reconciliation checks are what make people trust them, and they are what we put in place first in our web application development work. If your product's numbers are slow, disputed or both, talk to us about rebuilding reporting people can rely on.
Frequently Asked Questions
Why do two dashboards show different numbers for the same metric?
Usually because two queries are each correct for a slightly different definition. One counts revenue at signing and the other at invoicing, one nets refunds and the other excludes them, one uses the customer's time zone and the other the server's. The fix is to define each metric once, with its source, grain, time attribute, time zone, filters, additivity and owner, and make every chart, export and API read from it.
Should reports run on the production database?
Not for large scans. Operational databases are tuned for many small reads and writes, and running year-long aggregations on the primary slows the product for everyone, usually at month-end. Most products move from a read replica, to incrementally refreshed rollup tables, to a columnar store such as ClickHouse, BigQuery or Snowflake, a step justified by scan volume and ad-hoc analysis rather than by the word analytics on a roadmap.
Why can't you average daily averages in a report?
Because averaging daily averages weights a quiet day the same as a busy one, so the monthly figure disagrees with the same metric computed from raw rows. Ratios and averages should store their numerator and denominator separately and divide at query time. Distinct counts, snapshots such as balances, and percentiles cannot be summed across periods either, so record each metric's additivity in its definition.
How do you keep reports secure in a multi-tenant SaaS product?
Apply the same rules the product enforces, at the query rather than the screen. Every row carries a tenant id that the query layer filters on automatically, with row-level policies in the store as a second wall. Role scopes become query conditions, drill-downs re-check access on the underlying rows, caches are keyed by permission, and small groups are suppressed or merged for sensitive measures so a chart cannot reveal one person's data.
What should a CSV export feature handle?
Run large exports asynchronously, streaming rows to storage in chunks, and deliver them through short-lived signed links issued after a permission check. Neutralize formula injection by prefixing cell values that begin with =, +, - or @, add a UTF-8 byte-order mark so Excel reads accented names correctly, offer raw and formatted versions, and log every export with who ran it, which filters were used and how many rows it held.
