<@U088WCP3B4P> Can I configure anomaly tests to no...
# ask-elementary-ai
d
@kapa.ai Can I configure anomaly tests to not have negative values within their expected range? My metric cannot be negative, and if the expected range becomes negative the UI looks quite odd.
k
A message from kapa.ai
Yes, this issue has been recognized in Elementary, especially for metrics like row counts or volumes that logically cannot be negative. In earlier versions, the expected range for anomaly tests could include negative values due to the way the confidence interval was calculated (using mean and standard deviation, which can result in negative lower bounds if variance is high). This led to confusion and odd-looking UI, as you described. However, this behavior has been addressed in newer versions of the Elementary dbt package. The team implemented a fix to ensure that for metrics that cannot be negative (like row counts), the lower bound of the expected range is set to zero, avoiding negative values in the expected interval. This change was merged and released after version 0.10.0, so you should upgrade to at least version 0.10.3 or later to benefit from this fix. The relevant pull request is [here](https://github.com/elementary-data/dbt-data-reliability/pull/508) and the issue is discussed in detail in the community and GitHub threads [[Slack discussion](https://slack.com/archives/C02CTC89LAX/p1692860941789869), [GitHub issue](https://github.com/elementary-data/elementary/issues/1034)]. If you are still seeing negative expected ranges after upgrading, there may be additional configuration or edge cases, but the main fix for this issue is included in recent releases. There is not currently a user-facing configuration parameter to set hard lower bounds, but the default logic now prevents negative lower bounds for non-negative metrics. Summary: Upgrade to the latest version of the Elementary dbt package to ensure that expected ranges for non-negative metrics (like row counts) do not include negative values. This should resolve the odd UI and logical issues you described [[Slack discussion](https://slack.com/archives/C02CTC89LAX/p1692860941789869), [GitHub issue](https://github.com/elementary-data/elementary/issues/1034)].
d
What if it's not a trivial one? Can I configure this on a test-level basis?
@kapa.ai What if it's not a trivial one? Can I configure this on a test-level basis?
k
A message from kapa.ai
Based on the available knowledge sources, there is currently no documented way to configure non-negative lower bounds (or other logical bounds) on a per-test basis in Elementary. The fix to prevent negative lower bounds for certain metrics (like row counts) was implemented as a default behavior in the package, not as a user-configurable option. There have been community requests and GitHub issues suggesting the ability to set hardcoded lower and upper bounds at the test level, for example:
Copy code
yaml - elementary.volume_anomalies:     anomaly_sensitivity: 2.5     lower_bound: 0     upper_bound: 100000
However, this feature is not currently available. The Elementary team acknowledged the value of such a feature and discussed possibly adding a flag or configuration for "logical settings" (e.g., counts ≥ 0, percentages between 0 and 1), but as of now, this remains a feature request and is not implemented in the released versions [[GitHub issue](https://github.com/elementary-data/elementary/issues/1034)]. Summary: You cannot currently configure non-negative (or other) bounds on a per-test basis in Elementary. The only safeguard is the default logic for certain metrics in recent versions. If you need strict threshold-based validation, you may need to use dbt-expectations or custom dbt tests alongside Elementary anomaly tests [[Slack discussion](https://slack.com/archives/C02CTC89LAX/p1693901622870449)]. If this feature is critical for your use case, you may want to follow or contribute to the ongoing discussion in the relevant GitHub issue [[GitHub issue](https://github.com/elementary-data/elementary/issues/1034)].
🫠 1