# Calculated fields, CASE, groups and bins in Looker Studio

> Write calculated fields, CASE statements, custom groups and bins at data-source and chart level for marketing metrics.

Source: https://mentionx.ai/learn/looker-studio/looker-studio-calculated-fields  
Author: Dipuck Jones, founder of MentionX  
Updated: 5 November 2026  
Level: Practitioner

**Calculated fields turn raw connector fields into the metrics marketers actually discuss: conversion rate, CPA, blended ROAS, device groups, "AI vs other" channel flags. You can create them on a data source or on a single chart. This lesson covers formula patterns, CASE, custom groups and bins, the blend limitation, and how Gemini assistance (Pro) can draft formulas you still have to verify.**

> **Key takeaways**
>
> - Prefer **data-source fields** for definitions you reuse; use **chart-level fields** for experiments and blends.
> - **CASE** is how you rebuild channel logic and quality flags.
> - Data-source calculated fields **do not work in blends**; chart-level fields do.
> - Custom **groups** and **bins** beat nested CASE for simple bucketing.
> - Always show the formula in a report note the first week a metric goes to leadership.

*Checked 5 November 2026 (CET) against Google Cloud Data Studio documentation, the Data Studio product page, the Looker Studio-is-Data-Studio blog post, connector help pages and the Analytics Help pages cited in Sources. Google renames and moves features often, so confirm labels and limits in your own account. "Our view" marks MentionX opinion. Ledgerline is a fictional company used for illustration.*

## Data-source versus chart-level fields

| | Data-source calculated field | Chart-level calculated field |
|---|---|---|
| Where it lives | The data source field list | One chart's fields |
| Reuse | Every chart using that source | That chart only |
| Custom value formatting while creating | Limited; format in chart setup | Can set while creating |
| Works with blended data | No | Yes |
| Who can create | Needs edit rights on the data source | Needs edit rights on the report |

Google's calculated fields documentation is the source for these limits. Marketers hit the blend limitation constantly in cross-channel reports ([lesson 7](https://mentionx.ai/learn/looker-studio/looker-studio-blending-data-sources), [lesson 12](https://mentionx.ai/learn/looker-studio/looker-studio-cross-channel-roi-blend)).

## Core marketing formulas

Examples assume GA4-style names; rename to your fields.

**Conversion rate**

```text
SUM(Key events) / SUM(Sessions)
```

Set the field type to Percent.

**Cost per key event** (on a blend that already has Ads cost and GA4 key events — chart-level)

```text
SUM(Cost) / SUM(Key events)
```

**Safe divide** (avoid divide-by-zero)

```text
SUM(Key events) / NULLIF(SUM(Sessions), 0)
```

**AI Assistant flag** (dimension)

```text
CASE
  WHEN Session default channel group = "AI Assistant" THEN "AI Assistant"
  ELSE "Other"
END
```

**High-intent landing pages**

```text
CASE
  WHEN REGEXP_MATCH(Landing page, ".*/(pricing|demo|contact).*") THEN "High intent"
  ELSE "Other"
END
```

Test REGEXP on your real URL shapes. See also [GA4 key events](https://mentionx.ai/learn/ga4/ga4-key-events-setup) for what you should be counting.

## Custom groups and bins

Use **custom groups** when you map many campaign names into a few offers. Use **bins** when you bucket numeric metrics (for example session duration ranges). They are easier to maintain than a 40-line CASE when the rule is "these values become this label."

Rebuild groups when naming conventions change. Put the group definition owner in your connector register.

## CASE design rules for marketers

1. Order matters. First match wins.
2. Always include an ELSE, even if it is "Uncategorised".
3. Match on stable fields (channel group, medium) before brittle campaign strings when you can.
4. Document the business rule in a text box near the chart for the first two reporting cycles.
5. Do not silently redefine "conversion" differently on every page.

## Gemini assistance (Pro)

With Data Studio Pro and Gemini in Data Studio enabled, Google documents natural-language help for creating calculated fields. Treat the draft as a starting point. Run it against a known week and compare with GA4 Explorations before you publish. Gemini features have been in preview with limited support; confirm whether your project still shows preview notices ([lesson 19](https://mentionx.ai/learn/looker-studio/looker-studio-gemini-conversational-analytics)).

## Worked example: Ledgerline

*Ledgerline is a fictional accounts-payable software company. Details are illustrative.*

| Field | Type | Purpose |
|---|---|---|
| `Lead CVR` | Metric | Key events / sessions |
| `Intent page` | Dimension | Pricing/demo/contact vs other |
| `AI vs Other` | Dimension | AI Assistant channel flag |
| `Campaign family` | Custom group | Maps UTM campaigns into 5 offers |

### Walkthrough

1. Analysts created `Lead CVR` on the GA4 data source so every chart shared one definition.
2. `Intent page` started chart-level, then moved to the data source after two weeks of agreement.
3. A blend for Ads + GA4 needed chart-level CPA because the data-source CVR field could not be used on the blend.
4. Leadership asked why CVR differed from the GA4 UI. The footer linked to the exact formula.
5. Competitor C's agency used three incompatible CVR fields; Ledgerline refused to copy that mess.

> **Pro move:** keep a "metric dictionary" page in the report: metric name, formula, owner, date agreed. It prevents the quarterly argument about what a lead is.

## Formula patterns marketers reuse

| Need | Pattern | Notes |
|---|---|---|
| Safe divide | `SUM(X) / NULLIF(SUM(Y), 0)` | Avoid div-by-zero |
| Label channel | `CASE WHEN ... THEN ... ELSE "Other" END` | Keep ELSE |
| Brand vs non-brand | `REGEXP_MATCH(Query, "(?i)brand\|brandname")` | Test on Sample |
| Date week start | Use Date functions available in your field editor | Match targets Sheet |
| CPA | Cost / Conversions with NULLIF | Label which conversion |

## Data-source vs chart-level fields

| Level | Pros | Cons |
|---|---|---|---|
| Data source | Reusable across charts in reports using that source | Cannot feed blends; changes affect all reports on that source |
| Chart | Safe for blends; experiment freely | Easy to duplicate inconsistent formulas |

**Rule of thumb:** definitions you will defend in a QBR → data source (or warehouse). Blend rates → chart level.

## Blend limitation to memorise

Google documents that **data-source calculated fields cannot be used in blends**. If you need a blended CPA, create it as a chart-level calculated field on the blend. This single rule explains most "why did my field disappear" tickets.

## QA before you trust a field

1. Compare to the source UI for last 7 and last 28 days.
2. Check a day with zero conversions (NULLIF behaviour).
3. Ask a second person to read the CASE logic aloud.
4. Add the field to the metric dictionary.

## Functions marketers actually touch

| Category | Examples to learn | Avoid at first |
|---|---|---|
| Aggregation | SUM, COUNT, AVG, COUNT_DISTINCT | Nested aggregations you cannot explain |
| Text | CONCAT, LOWER, REGEXP_MATCH, REGEXP_EXTRACT | Ultra-complex multi-capture regex |
| Logic | CASE, IF, COALESCE, NULLIF | Deeply nested CASE trees |
| Date | DATE_DIFF, FORMAT_DATETIME as available | Time-zone maths without a specialist |

Open Google's calculated field function list from the field editor when unsure — function availability can differ slightly by context. Prefer readable formulas over clever one-liners.

## Common mistakes

- **Different CVR formulas on different pages.**
- **Trying to use a data-source calculated field inside a blend.**
- **CASE without ELSE**, dropping rows into nulls.
- **Regex that only matches desktop URL casing.**
- **Publishing Gemini-drafted formulas untested.**

## Try it yourself

On your GA4 data source, add a percent `Key event rate` field and a CASE that flags AI Assistant versus Other. Drop both onto a table with Session source and confirm totals look sane for the last 28 days.

## Quick quiz

**1. Can data-source calculated fields be used with blended data?**

*Answer:* No. Use chart-level calculated fields on the blend.

**2. What does NULLIF help with in rate metrics?**

*Answer:* Preventing divide-by-zero when the denominator is 0.

**3. When are custom groups better than CASE?**

*Answer:* When you are simply bucketing many dimension values into a few labels.

## What should you check before the next lesson?

- At least one reusable calculated metric exists.
- Blend limitation understood.
- Metric dictionary stub started.

Previous: [Build your first marketing dashboard in Looker Studio](https://mentionx.ai/learn/looker-studio/looker-studio-first-marketing-dashboard). Next: [Parameters, filters and controls in Looker Studio](https://mentionx.ai/learn/looker-studio/looker-studio-parameters-filters-controls). Or return to the [Looker Studio for Marketers track](https://mentionx.ai/learn/looker-studio/looker-studio-for-marketers). Related: [GA4 key events setup](https://mentionx.ai/learn/ga4/ga4-key-events-setup), [GA4 default channel group explained](https://mentionx.ai/learn/ga4/ga4-default-channel-group-explained), [Claude CSV analysis for GA4 and Ads](https://mentionx.ai/learn/claude/claude-csv-analysis-ga4-ads).

## Common questions

**What is a calculated field in Looker Studio?** A formula that creates a new dimension or metric from existing fields, using functions, arithmetic or CASE logic.

**Can I use a data-source calculated field in a blend?** No. Google documents that data-source calculated fields cannot be used with blended data. Use a chart-level calculated field on the blend instead.

**What are custom groups and bins?** Custom groups bucket dimension values into labels you define. Custom bins bucket numeric values into ranges. Both are calculated-field types in Data Studio.
## Sources

- Google Cloud, [About calculated fields](https://docs.cloud.google.com/data-studio/about-calculated-fields)
- Google Help, [About calculated fields (Looker Studio Help)](https://support.google.com/looker-studio/answer/6299685)
- Google Cloud, [Create calculated fields with Gemini assistance](https://docs.cloud.google.com/data-studio/create-calculated-fields-gemini)
- All accessed 5 Nov 2026.

## Frequently asked questions

### What is a calculated field in Looker Studio?

A formula that creates a new dimension or metric from existing fields, using functions, arithmetic or CASE logic.

### Can I use a data-source calculated field in a blend?

No. Google documents that data-source calculated fields cannot be used with blended data. Use a chart-level calculated field on the blend instead.

### What are custom groups and bins?

Custom groups bucket dimension values into labels you define. Custom bins bucket numeric values into ranges. Both are calculated-field types in Data Studio.

---

Written and reviewed by Dipuck Jones for MentionX Learn. The HTML version of this page: https://mentionx.ai/learn/looker-studio/looker-studio-calculated-fields
