refunds source from
Connect your data, with refunded_at and amount columns.
1. Sum a column
Every file undermetrics/ is one metric, named after the file. Create
metrics/refunded_amount.yaml:
tablenames the source andcolumnwhat to add up.timeis the date that places a row in a period. Set it on almost every metric.better: downcolours a rise red on every KPI.
2. Count rows
metrics/refunds.yaml counts rows, so it needs no column:
filters keeps only some rows, such as status: paid in the sample orders metric. See
filters.
3. Divide two metrics
A rate is aratio of two metrics, here the refunds over the sample project’s orders. Create
metrics/refund_rate.yaml:
4. Check the numbers
query computes values exactly as a dashboard card does. Compare one against a number you trust,
such as a total from hatchmark data query. hatchmark explain refund_rate prints the SQL behind it.
5. Pin a value
Add a test with the value you checked, sohatchmark test fails when a change to the data or the
definition moves it:
Next
- Build a dashboard with the new metrics.
- Metrics lists every metric type:
sql,formula,per_entityand point-in-time metrics over snapshots.