High severityquery
Power BI Refresh Error:
MULTI_VALUE_SUBQUERY_ERROR
What does this error mean?
A scalar subquery (used in a position that expects a single value) returned more than one row. Spark SQL raises this error at runtime when the subquery result set has more than one row.
Common causes
- 1A subquery in a SELECT list or WHERE = clause that is expected to return one row but returns multiple rows at runtime
- 2A subquery used with `= ` instead of `IN` when the source data has grown to contain duplicates
- 3Missing LIMIT 1 on a lookup subquery
- 4JOIN condition not unique, causing a previously single-row subquery to return multiple rows after a data change
How to fix it
- 1Add `LIMIT 1` to the subquery if returning the first match is acceptable
- 2Use an aggregation (MAX, MIN, ANY_VALUE) inside the subquery to collapse multiple rows into one
- 3Change `= (subquery)` to `IN (subquery)` if multiple values are valid matches
- 4Investigate the source data change that caused the subquery to return multiple rows and fix the root cause
- 5Rewrite as a JOIN if the intent is to match all rows rather than a single scalar value