metricsign
Start free
Medium severityquery

Power BI Refresh Error:
1111

What does this error mean?

An aggregate function (SUM, COUNT, MAX, etc.) is used in a WHERE clause instead of a HAVING clause.

Common causes

  • 1Using WHERE COUNT(*) > 10 instead of HAVING COUNT(*) > 10
  • 2Aggregate functions in a subquery WHERE condition referencing the outer query incorrectly
  • 3dbt model uses aggregate in a WHERE filter instead of HAVING

How to fix it

  1. 1Step 1: Move aggregate conditions from WHERE to HAVING: `SELECT col, COUNT(*) FROM t GROUP BY col HAVING COUNT(*) > 10;`
  2. 2Step 2: If filtering on an aggregated subquery result, use a derived table: `SELECT * FROM (SELECT col, COUNT(*) AS cnt FROM t GROUP BY col) sub WHERE sub.cnt > 10;`
  3. 3Step 3: In dbt, review any WHERE clauses in grouped models for misplaced aggregates.

Frequently asked questions

What is the difference between WHERE and HAVING in MySQL?

WHERE filters rows before grouping (cannot reference aggregates). HAVING filters groups after aggregation (can reference aggregates). Use WHERE for row-level filters and HAVING for group-level filters.

Can I use both WHERE and HAVING in the same MySQL query?

Yes: `SELECT col, COUNT(*) FROM t WHERE status='active' GROUP BY col HAVING COUNT(*) > 5;` — WHERE filters rows first, then grouping and aggregation happen, then HAVING filters groups.

Can MetricSign detect when an aggregate function error breaks a pipeline?

Yes — MetricSign captures ADF pipeline failures and surfaces the MySQL error code, letting you identify query logic errors in Lookup or Script activities.

Official documentation: https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html

Other query errors