Executive summary
BigQuery introduced a WHERE clause inside aggregate function calls in Preview on September 14, 2026. It lets a query filter the inputs to an individual aggregate without filtering the rows available to other measures in the same SELECT. For reporting teams, the attraction is not a dramatic new calculation. It is the ability to express conditional measures more directly, reduce repetitive CASE expressions and make metric definitions easier to review.
The benefit is conditional, not automatic. Cleaner syntax does not repair an incorrect join, unclear KPI denominator, inconsistent date rule or missing data-quality test. And because the feature remains labeled Preview in Google’s documentation as of November 2026, production adoption needs a compatibility and rollback decision rather than a blanket rewrite of established models.
The practical recommendation: test the feature on a small number of high-value conditional measures, compare results against existing SQL, document the approved metric definition and promote only when your deployment standards permit Preview features.
What changed in BigQuery?
Traditional SQL commonly implements conditional sums using SUM(CASE WHEN condition THEN value ELSE 0 END), and conditional counts using COUNTIF(condition) or COUNT(CASE WHEN condition THEN 1 END). BigQuery now documents a predicate inside the aggregate call itself, such as SUM(amount WHERE status = ‘paid’). The outer SELECT still sees the original group of rows; the predicate determines which rows that specific aggregate receives.
Google’s aggregate-function reference describes the syntax as function_name(arguments [ WHERE boolean_expression ]), subject to each function’s supported clauses. The exact placement is inside the parentheses, after the function argument and any applicable NULL-handling modifier, not after the SELECT or GROUP BY. The feature was announced September 14, 2026 and remains Preview in the current reference. Read the official BigQuery aggregate-function syntax before using less common combinations of modifiers.

Consider a report that needs all orders, paid revenue and the number of refunded orders for each month. A global WHERE status = ‘paid’ would remove non-paid orders from every measure. An aggregate-local WHERE filters only the metric that needs it. That distinction is the central reason the feature matters for multi-KPI reporting.
A concrete example: three KPIs from one grouped dataset
The following self-contained sample is illustrative. It is not a customer case study or a performance benchmark. The order amounts and dates are invented solely to demonstrate the SQL semantics.
WITH orders AS (
SELECT DATE ‘2026-10-02’ AS order_date, ‘paid’ AS status, 120 AS amount UNION ALL
SELECT DATE ‘2026-10-03’, ‘refunded’, 80 UNION ALL
SELECT DATE ‘2026-10-04’, ‘pending’, 50 UNION ALL
SELECT DATE ‘2026-10-05’, ‘paid’, 200
)
SELECT
DATE_TRUNC(order_date, MONTH) AS month,
COUNT(*) AS all_orders,
SUM(amount WHERE status = ‘paid’) AS paid_revenue,
COUNT(* WHERE status = ‘refunded’) AS refunded_orders
FROM orders
GROUP BY month;
Expected result for October 2026: all_orders = 4, paid_revenue = 320 and refunded_orders = 1. Notice that the pending and refunded rows still contribute to all_orders. The WHERE inside SUM affects only paid_revenue, while the WHERE inside COUNT affects only refunded_orders.
The equivalent established pattern is:
SELECT
DATE_TRUNC(order_date, MONTH) AS month,
COUNT(*) AS all_orders,
SUM(CASE WHEN status = ‘paid’ THEN amount ELSE 0 END) AS paid_revenue,
COUNTIF(status = ‘refunded’) AS refunded_orders
FROM orders
GROUP BY month;
Both patterns express the same intended measures for this sample. The second version has broader familiarity and uses established constructs. The first makes the input filter visually adjacent to the aggregate. Neither approach is inherently more correct. The right choice depends on team conventions, preview policy, function compatibility and the results of regression testing.
Why this is a reporting-governance issue, not just a syntax update
Executive reporting frequently contains dozens of conditional measures: recognized revenue, open pipeline, late shipments, active customers, resolved tickets and exceptions. When each metric repeats long CASE expressions, reviewers have to compare conditions spread across a large SELECT list. Small differences can be legitimate, but they can also be accidental: one measure excludes test accounts, another does not; one uses local dates, another UTC; one counts canceled orders, another silently excludes them.
Aggregate-local filtering can make these differences easier to spot. The measure name, aggregation and row eligibility condition sit together. That is a readability advantage, not a substitute for a governed semantic model. Teams still need a canonical definition of ‘paid,’ ‘active,’ ‘net,’ ‘completed’ and other business terms, including the treatment of reversals, duplicates and late-arriving records.

This is why the change belongs in a wider discussion of BI architecture. Actiknow’s business intelligence services describe integration, modeling, reporting and refresh as parts of one delivery process; conditional aggregation should be reviewed in that end-to-end context rather than treated as an isolated SQL cleanup.
Five situations where the syntax is useful
- Multi-status operational scorecards. A single daily grain can return all tickets, overdue tickets, escalated tickets and closed tickets. Each measure keeps its own eligibility rule while preserving a shared population. This reduces the temptation to duplicate the base query for every status.
- Finance and revenue reconciliation. Teams often need gross billed amount, collected amount, credited amount and disputed amount side by side. Explicit per-aggregate predicates can expose whether the measures overlap and whether the totals should reconcile. The accounting policy still decides what each bucket means.
- Marketing funnel reporting. One grouped table can compute eligible leads, qualified leads and converted leads. However, the denominator for conversion rate must be named and reviewed separately. Filtering a numerator does not automatically select the correct population for a ratio.
- Service-level reporting. A measure might sum handling time only for completed cases while counting all received cases. This is valid only if the dashboard explains that average handling time applies to completed cases, not every incoming request.
- Data-quality monitoring. A model can count all rows alongside rows with missing IDs, negative amounts or failed validation flags. Per-aggregate conditions are useful for transparent exception summaries, especially when checks are reviewed by both engineering and business owners.
The important difference between WHERE in SELECT and WHERE in an aggregate
A top-level WHERE clause removes rows before grouping. It affects every aggregate in that query block. An aggregate-local WHERE restricts inputs for one function. A HAVING clause filters grouped results after aggregation, and QUALIFY filters results involving window functions. These clauses answer different questions, even though all use predicates.
For example, WHERE region = ‘West’ defines the population for the entire report. SUM(amount WHERE status = ‘paid’) defines which of those West-region rows contribute to paid revenue. HAVING SUM(amount) > 1000 would then exclude groups whose aggregate total fails a threshold. Mixing these purposes is a common source of discrepancies between dashboards.
Use top-level WHERE for universal scope such as permitted business units, approved reporting periods and legitimate source records. Use aggregate-local WHERE for measure-specific eligibility. Use HAVING when the decision concerns grouped output. Do not shift security rules or row-level access policy into measure predicates: security must be enforced independently.
COUNT, COUNTIF and NULL: small details with large consequences
Google’s own documentation illustrates COUNT(* WHERE x IS NOT NULL). The COUNT(*) form counts the rows admitted by its local predicate. COUNT(column) normally counts only non-NULL column values. COUNTIF(condition) counts rows where the condition evaluates to TRUE. These are often equivalent for a simple Boolean condition, but the intended semantics should be explicit.
NULL deserves special care in sums and averages. SUM(amount WHERE eligible) ignores NULL amount values among eligible rows, while SUM(CASE WHEN eligible THEN amount ELSE 0 END) introduces zero for ineligible rows. For SUM, the numerical totals may match in ordinary nonempty groups, but empty-match and all-NULL cases can differ. For AVG, replacing ineligible values with zero changes the denominator and is generally not equivalent to filtering those rows.
Example: suppose there are two paid orders, with amounts 100 and 200, and one pending order worth 900. AVG(amount WHERE status = ‘paid’) is 150. AVG(CASE WHEN status = ‘paid’ THEN amount ELSE 0 END) is 100 because the pending order contributes a zero to the average. The correct legacy equivalent is typically AVG(CASE WHEN status = ‘paid’ THEN amount END), which yields NULL for excluded rows. This is not a cosmetic difference; it changes the reported KPI.
When no rows match the aggregate predicate, COUNT(* WHERE …) returns zero, while SUM and AVG can return NULL. A dashboard that expects zero revenue may need COALESCE around the sum. Decide that treatment in the metric contract rather than leaving it to each dashboard author.
Ratios still require explicit denominator design
The new syntax is most valuable when it makes both sides of a rate readable. A conversion rate might be expressed as SAFE_DIVIDE(COUNT(* WHERE converted), COUNT(* WHERE eligible)). That expression is only meaningful if converted and eligible describe compatible event grains, conversion windows and deduplicated entities.
Imagine 1,000 lead events but only 600 unique leads. Counting conversion events in the numerator and unique leads in the denominator produces a different rate from counting distinct converted leads over distinct eligible leads. Aggregate-local WHERE cannot solve the grain mismatch. Define the unit of analysis first, then choose the SQL.
For financial metrics, be equally explicit about currency conversion, tax treatment, credits, cutoffs and partial refunds. Simpler expressions make errors easier to review only when reviewers know what the expression is supposed to mean.
Where readability can backfire
A short WHERE clause inside a long SELECT can conceal a complex business rule if the predicate is repeated differently across measures. For example, status = ‘paid’ may not cover late settlements, chargebacks or migrated statuses. Moving the condition inside SUM does not make it authoritative. When rules are reused across dozens of models, centralize them in an approved intermediate model or semantic layer.
Avoid treating aggregate predicates as replacements for pre-aggregation data cleansing. Duplicated join rows will still inflate SUM, and conflicting source records will still produce inconsistent counts. Resolve entity keys, join cardinality and source precedence upstream. Then write aggregates over a trustworthy grain.
Also avoid assuming every SQL client, transformation tool or linter understands a Preview grammar. A query may run in BigQuery while a static analyzer, SQL formatter, BI connector or third-party parser rejects it. That is a release compatibility issue, not a problem solved by adding comments.
Does the new syntax make BigQuery faster or cheaper?
There is no reliable basis for claiming that SUM(amount WHERE condition) is faster than an equivalent SUM(CASE…) across workloads. The SQL is shorter, but query cost depends on bytes scanned, partition pruning, joins, shuffle, aggregation cardinality, slot use and the optimizer’s chosen plan. In many queries, the dominant cost occurs before the aggregate is evaluated.
A global WHERE can sometimes reduce the amount of data processed by eliminating rows early; an aggregate-local WHERE must preserve rows needed by other measures. These two queries are not performance-equivalent when they answer different questions. Do not move a universal filter inside aggregates merely to adopt the feature.

Benchmark with representative data and production-like parameters. Record bytes processed, slot milliseconds, elapsed time and result equality. Run multiple trials, account for cache behavior and compare query plans. If performance is unchanged but code review becomes materially easier, that can still justify adoption. Conversely, shorter SQL alone is not an adequate business case for a migration.
A safe migration and testing approach
Step 1: Inventory conditional aggregates. Identify repeated CASE expressions and COUNTIF measures in high-change models. Prioritize those with frequent metric defects or complicated review, not every query in the warehouse.
Step 2: Write a metric contract. For each measure, specify grain, input table, eligibility predicate, aggregation, NULL behavior, timezone, currency rules, expected empty-group behavior and reconciliation relationship. Name the business owner and technical owner.
Step 3: Build an old-versus-new comparison. Execute the established and new SQL against the same fixed input. Compare every grouped key and measure, not just grand totals. Include segments with no eligible rows, NULL amounts, duplicate identifiers, reversals, negative values and late-arriving updates.
Step 4: Test supported syntax and tooling. Confirm the function and clause combination in the official reference. Check your deployment region and project, transformation compiler, SQL formatter, code-quality tools and downstream BI clients. Do not assume Preview features are uniformly available in every integration.
Step 5: Review performance. Use representative partitions and realistic joins. Measure cost and latency separately from readability. A syntax improvement should not be sold as a performance optimization without evidence.
Step 6: Promote behind an explicit release decision. Keep the established SQL available as a rollback. Require code review, automated comparison tests and signoff from the metric owner for executive-facing measures. If your organization forbids Preview features in production, retain the legacy form.
Step 7: Monitor after deployment. Compare dashboard totals to control reports for at least one relevant reporting cycle. Track changes in source statuses and dimension mappings that can invalidate eligibility conditions even when the SQL continues to run.

A compact regression test matrix
At minimum, test: (a) a normal group with eligible and ineligible rows; (b) a group with zero eligible rows; (c) NULL amounts in eligible rows; (d) all-NULL eligible amounts; (e) duplicate source IDs; (f) a left join that creates NULL dimension fields; (g) negative adjustments and refunds; (h) mixed-case or unknown status values; (i) an empty input table; and (j) an unexpected new status. Record expected outcomes, not merely whether the query executes.
A useful assertion is that paid revenue from the new expression equals the approved CASE expression for every business unit and month. Another is that a mutually exclusive status breakdown reconciles to all orders, after accounting for unknown statuses. When measures intentionally overlap, document that the sum of categories should not equal the overall total.
What to standardize in your SQL style guide
Keep business conditions close to metric names, use consistent aliases, and prefer explicit status lists over implicit assumptions. Avoid hidden conversions inside aggregation when they can be normalized upstream. Use SAFE_DIVIDE for ratios where zero denominators are possible. Use COALESCE only when the business definition truly requires zero rather than missing data.
Require an explanatory comment for non-obvious denominators and for overlapping categories. Document whether each measure counts rows, events, orders, customers or distinct entities. Prefer one approved definition of an eligible transaction over several slightly different local variants.

If teams maintain dashboards in multiple tools, establish a single semantic owner for core metrics. Actiknow’s BI dashboard development page discusses integrating data sources, preparing models and testing dashboards, all relevant when a warehouse SQL change affects downstream executive reports.
A four-week adoption plan
Week 1
Select two or three representative reporting models. Document existing metrics, source grains, owners and current test coverage. Decide whether Preview syntax is permitted in non-production environments.
Week 2
Build alternate queries and an automated comparison harness. Test normal, edge and empty groups. Capture parser compatibility across your development, deployment and reporting tools.
Week 3
Review with the BI owner and a business stakeholder. Compare code clarity, test results and query statistics. Decide whether the change is worth the additional Preview dependency.
Week 4
If permitted, release one low-risk model with rollback and monitoring. Publish a short style guide. Otherwise, retain the test findings and revisit when the feature becomes generally available.
Success is not the number of CASE expressions deleted. Better measures are fewer unexplained KPI differences, faster reviews of conditional metric changes, explicit metric ownership and regression tests that catch a wrong predicate before executives see it.
Questions executives and BI leaders should ask
Ask the team to show one metric before and after the change, the edge cases that were tested, the proof that totals reconcile, the current product support status and the rollback route. If the only evidence is that the query looks shorter, the release decision is premature.
Ask whether the measure’s eligibility rule is already governed. If not, fund the definition and ownership work before the syntax migration. A one-line aggregate over the wrong population is still a wrong KPI.
Frequently asked questions
Is BigQuery aggregate WHERE generally available?
No. Google announced the capability on September 14, 2026 and currently labels the aggregate-local WHERE clause Preview. Verify the latest release status and your organization’s pre-GA policy before production use.
How is aggregate WHERE different from the normal WHERE clause?
A top-level WHERE filters rows for the entire query block. A WHERE inside an aggregate filters only the rows passed to that aggregate, leaving other aggregates free to use different subsets of the same group.
Can I replace every SUM(CASE WHEN …) with SUM(… WHERE …)?
Not automatically. Check NULL and empty-group behavior, ELSE values, data types and whether the old expression intentionally includes zeros. Compare results at the grouped-key level before changing a production model.
Is COUNT(* WHERE condition) the same as COUNTIF(condition)?
For a straightforward Boolean condition, both count matching rows. They are not a substitute for defining whether the metric counts events, distinct entities or another business grain.
What happens when no rows satisfy the condition?
COUNT returns zero, while SUM and AVG can return NULL. Choose whether to preserve NULL or convert it to zero based on the business meaning of an empty eligible population.
Does aggregate WHERE replace HAVING?
No. Aggregate WHERE selects the input rows for a function. HAVING filters groups based on aggregate results. They operate at different stages of a query.
Does the feature automatically reduce query cost?
No documented general speed or cost advantage should be assumed. Measure bytes processed, slot consumption and latency on representative workloads, and verify that compared queries compute the same result.
Can I use it with DISTINCT or window functions?
Support depends on the function and clause combination. Google’s reference defines modifier ordering and notes restrictions for aggregate clauses used with OVER. Test the exact expression rather than extrapolating from a simple SUM example.
Should a regulated organization use this in production?
Follow the organization’s Preview-feature policy and control requirements. If production use is prohibited, keep established SQL while using the new syntax in an isolated evaluation. Reassess at general availability.
What is the most important test before rollout?
A row-by-row comparison of grouped results between the approved existing metric and the proposed expression, including NULLs, zero-match groups, duplicates and adjustments. Correctness must precede style preferences.
Conclusion: clearer SQL is valuable when the definition is correct
BigQuery’s aggregate-local WHERE clause can make conditional reporting SQL easier to read and maintain. The improvement is real but narrow: it expresses a per-measure filter more directly. It does not eliminate metric governance, source reconciliation, testing or performance analysis. Treat it as a controlled SQL-language enhancement, not an analytics transformation program.
If your team is revisiting complex warehouse metrics, Actiknow’s BI consulting and dashboard work can help assess the data model, reporting definitions and validation approach. Share the specific reporting challenge through Actiknow’s contact page to discuss whether a focused review would be useful.
References and feature status
Google Cloud BigQuery release notes, September 14, 2026: announcement of WHERE inside aggregate calls (Preview).
Google Cloud GoogleSQL aggregate-function calls reference: grammar, modifier order, NULL behavior and Preview designation.

