Skip to main content

Standard query metric examples

Order line item reconciliation: Compute the relative discrepancy between line item totals and order totals. A result above 0.01 (1%) triggers an alert — catching ETL bugs where line items were loaded without the parent order record updating.
Detecting negative balances: Count active customer accounts with a negative balance. Set threshold to > 0 for zero tolerance — any active account with a negative balance is a business rule violation.
Query metrics run with the credentials of the connected source. Ensure the service account has SELECT access to all tables referenced in the query. Queries that modify data (INSERT, UPDATE, DELETE) are not permitted and will be rejected.

Parameterized query metric examples

Rolling window checks

Goal: Run the same check for the last 7, 30, or 90 days without creating separate metrics.
Run for different windows via the popup or CLI:
Each run produces a separate result entry with the parameter values recorded in the audit log.

Partitioned execution by date

Goal: Validate data quality for a specific partition (e.g., effective date) and re-run for historical dates independently.
Re-run for a different date by changing effective_date in the popup — the metric definition stays the same.

Segmented KPI validation

Goal: Apply the same revenue completeness check for each sales region using one metric definition.
Both runs share the same metric ID — results are tagged with their effective parameter values.

Threshold injection (pass/fail in-query)

Goal: Encode the pass/fail decision directly into the SQL so the warehouse handles it rather than Prizm’s threshold layer.
Different teams can supply different min_revenue thresholds for the same underlying table without duplicating metric definitions.

Region-specific REGEX validation

Goal: Validate that a material type code (MTART) matches the correct format for each region — format differs per region.
When the same REGEX rule needs to run against many tables — each with its own override — use a Metric Template instead. See the Metric Template overview for template-based use cases.