harsha reddy
04/23/2026, 5:55 PMkapa.ai
04/23/2026, 5:56 PMmetrics_anomaly_score view computes training_avg, training_stddev, and consequently anomaly_score using a window function partitioned only by metric_name, full_table_name, and `column_name`:
avg(metric_value) over (
partition by metric_name, full_table_name, column_name
order by bucket_start asc
rows between unbounded preceding and current row
) as training_avg
This means the statistics are calculated across all dimension values combined, rather than per slice/dimension value. [Partition bug]
The expected behavior (as described in the GitHub issue) is that the partition should also include dimension and `dimension_value`:
avg(metric_value) over (
partition by metric_name, full_table_name, column_name, dimension, dimension_value
order by bucket_start asc
rows between unbounded preceding and current row
) as training_avg
This discrepancy explains why the metrics_anomaly_score view shows different averages/stddevs than what the Elementary dashboard displays â the dashboard likely computes stats per dimension value correctly, while the view does not. [Partition bug]
Current status: The GitHub issue was closed due to inactivity (marked stale), but based on the knowledge sources, the fix has not been confirmed as merged into a specific release. The SQL in version 0.21.0 still shows the problematic partitioning. [Partition bug]
Workaround: You can locally override metrics_anomaly_score.sql in your own dbt project by copying the package SQL and adding dimension, dimension_value to the partition by clause in all window functions. To do this:
1. Disable the package model in `dbt_project.yml`models
elementary:
metrics_anomaly_score:
+enabled: false
2. Create models/elementary_overrides/metrics_anomaly_score.sql with the corrected partition:avg(metric_value) over (
partition by metric_name, full_table_name, column_name, dimension, dimension_value
order by bucket_start asc
rows between unbounded preceding and current row
) as training_avg,
{{ elementary.standard_deviation('metric_value') }} over (
partition by metric_name, full_table_name, column_name, dimension, dimension_value
order by bucket_start asc
rows between unbounded preceding and current row
) as training_stddev
[local override]
I'd recommend also checking the Elementary Slack or reopening the GitHub issue to confirm whether a fix has been released in a version newer than 0.21.0. đ 0 button đ 0 button âšī¸ Tip: Mention @elementary.ai in the thread for follow-ups or DM the app for 1-to-1 help.