According to the Elementary Data documentation, the dimensions parameter in anomaly detection tests (such as dimension_anomalies) does support SQL expressions, not just column names. The docs state: > The test will group the results by a given column / columns / valid select sql expression. Under dimensions you can configure the group by expression. > — [Elementary Docs: dimensions](
https://docs.elementary-data.com/data-tests/anomaly-detection-configuration/dimensions) However, there are some practical limitations and caveats: - The expression must be a valid SQL expression for your data warehouse and compatible with how dbt and Elementary generate the underlying queries. - There have been user reports of certain SQL expressions (especially those with special characters or complex logic) causing errors, depending on the data warehouse and how the expression is parsed. For example, a user reported issues with expressions containing special characters in Snowflake, even though the expression was valid SQL for that warehouse. Quoting and syntax can be sensitive in these cases, and sometimes the error is due to how the YAML or dbt parses the expression, not Elementary itself. [Slack forum discussion](
https://slack.com/archives/C02CTC89LAX/p1710839449760619) - The documentation and community examples show that simple SQL expressions (such as CASE statements or window functions) can work, but more complex expressions or those with special characters may require extra care or may not be supported in all environments. [Slack forum discussion](
https://slack.com/archives/C02CTC89LAX/p1689188556729539) In summary: Yes, SQL expressions are supported in dimensions, but support may be limited by your data warehouse's SQL dialect, quoting, and how dbt/Elementary parse the YAML. If you encounter errors, try simplifying the expression, check for quoting issues, or test the expression directly in your warehouse. If problems persist, it may be a limitation or bug, and reaching out to the Elementary community or support is recommended. For your specific example, ensure the SQL expression is valid for your warehouse and try quoting or formatting adjustments if you encounter errors. If it still fails, it may be a current limitation. [Elementary Docs: dimensions](
https://docs.elementary-data.com/data-tests/anomaly-detection-configuration/dimensions)