Does the where_expression filters the training dat...
# ask-elementary-ai
a
Does the where_expression filters the training dataset or the tested dataset ?
k
A message from kapa.ai
Based on the knowledge sources, the
where_expression
parameter filters both the training dataset and the tested dataset - essentially, it filters the entire monitored dataset before any metrics are collected. According to the [where_expression documentation](https://docs.elementary-data.com/data-tests/anomaly-detection-configuration/where-expression), it is used to "Filter the tested data using a valid sql expression." This filtering is applied to the monitored data set as a whole, as indicated in the [core concepts documentation](https://docs.elementary-data.com/data-tests/how-anomaly-detection-works#tests-configuration-and-core-concepts). This is further confirmed in a [GitHub discussion](https://github.com/elementary-data/elementary/issues/980) where a contributor explained: "When you add a
where_expression
to a test Elementary would 'reset' the metrics (as this is a change to the underlying dataset) and will recalculate the metrics without the excluded rows." If you need to exclude specific metrics from only the training set (without affecting the detection/tested data), you should use the [
anomaly_exclude_metrics
](https://docs.elementary-data.com/data-tests/anomaly-detection-configuration/anomaly-exclude-metrics) parameter instead, which allows you to filter metrics based on
metric_date
,
metric_time_bucket
, or
metric_value
.