pbPassingBI
/
Fields & calculations intermediate 9 min

Calculated fields

Formulas, aggregation rules, CASE logic and the source-vs-chart distinction.

What you'll be able to do
  • Write calculated fields with CASE and arithmetic
  • Explain source-level vs. chart-level fields
  • Avoid the aggregation mistakes that produce wrong ratios

Where fields live

A data source calculated field is defined once on the source and available to every chart and report using it. A chart-level field exists only in that chart.

Define at source level unless the calculation is genuinely specific to one chart. Chart-level fields scatter logic and are invisible to anyone auditing the source.

Common functions

Text: CONCAT, REGEXP_EXTRACT, REGEXP_MATCH, LOWER, TRIM, SUBSTR.

Logic: CASE WHEN condition THEN result ... ELSE fallback END, and IF(condition, then, else).

Dates: DATE_DIFF, DATETIME_TRUNC, PARSE_DATE.

A typical bucketing field:

CASE
  WHEN Sessions > 1000 THEN "High"
  WHEN Sessions > 100 THEN "Medium"
  ELSE "Low"
END

Aggregation is where people go wrong

A calculated field defined as Revenue / Sessions computes per row and then aggregates — averaging per-row ratios, which is wrong.

The correct form aggregates first: SUM(Revenue) / SUM(Sessions).

This is exactly the same trap as AVG(a/b) versus SUM(a)/SUM(b) in any other tool, and it is the single most common source of subtly wrong numbers in Looker Studio reports.

Set the field's aggregation to Auto when the formula already aggregates; leave it as Sum only when the expression is genuinely row-level.

Parameters

Parameters are user-input values — a number, text, date or a list of options — that can be exposed as a control and referenced in calculated fields.

They drive metric switching (CASE WHEN Selected Metric = "Revenue" THEN SUM(Revenue) ... END), threshold inputs, and pass-through values into a BigQuery custom query. They are the main route to interactivity beyond ordinary filters.

Key points
  • Define fields at source level so they are shared and auditable
  • Ratios must be SUM(a)/SUM(b), not a row-level division
  • Parameters drive metric switching and threshold inputs
Check yourself