Connect with us


How To Unlock Better Google Data Studio Segments Using “CASE”



How To Unlock Better Google Data Studio Segments Using “CASE”

Imagine you’re looking at a bar chart of Google Ads conversions by month in Google Data Studio.

You want to know how brand campaigns are affecting performance.

Image by author, April 2022

You decide to add Campaigns as a “breakdown dimension” so you can see conversions by campaign.

That segmentation doesn’t give you the result you’d hoped:

Stacked bar chart with more than 40 campaignsImage by author, April 2022

With dozens of campaigns across multiple accounts, this chart is far too noisy to be useful.

So… what now?

You could create a filter for brand campaigns.

However, that will filter out any non-brand campaign performance – which you don’t want to do.

If it were supported, importing your labels from Google Ads would solve the problem.


How can you create your own segments in Data Studio, so you’re fully in control of your visualizations and can drive better insights?

Answer: CASE.

This CASE statement lets you group the branded and non-branded campaigns into two separate segments:

New field screen in Data Studio showing CASE statement grouping campaignsScreenshot taken by author, April 2022

Using the above code, campaigns that don’t include “Brand” (or the Dutch language “Merknaam”) will be grouped as “NonBrand.”

The final result is exactly what we hoped for: A stacked bar chart with a breakdown dimension showing conversion totals for only “Brand” and “NonBrand” campaign groups.

Stacked bar chart of brand and nonbrand campaign groups over timeImage by author, April 2022

The trend in this chart is clear: Brand conversions have been steadily declining over the year.

That insight can now drive a strategy to address the issue.

If using CASE to get custom segments in Data Studio has left you frustrated and bewildered, fear not.

This article will show you how to use CASE with confidence, and give you some examples you can apply directly to your reports for better visualizations.

The Case For CASE

It’s hard to discuss CASE expressions without getting a little technical, so let’s start with W3 School‘s definition of a CASE statement:


The CASE statement goes through conditions and returns a value when the first condition is met (like an if-then-else statement). So, once a condition is true, it will stop reading and return the result.

If no conditions are true, it returns the value in the ELSE clause. If there is no ELSE part and no conditions are true, it returns NULL.

In other words, you set the conditions for your segment (“brand campaigns” in the example above).

If the condition is met (campaign name contains “brand”), it’s included in the Brand group. If the condition is not met (campaign name does not contain “brand”), it’s in the NonBrand group.

If that illustration sounds overly simplistic, let’s look at a slightly more complex scenario for using CASE from Google Data Studio’s Help pages:

A common use for CASE is to create new categories or groupings of data. For example, to group selected country values into a Sales Region dimension, you might create a CASE expression like this:


WHEN Country IN (“USA”,”Canada”,”Mexico”) THEN “North America”
WHEN Country IN (“England”,”France”) THEN “Europe”
ELSE “Other”


In this example, five different countries are consolidated into two different continents, with an “other” category to catch any additional countries.


A list of dozens or even hundreds becomes a clean list of three.

The Power Of Data Studio CASE Expressions

Simplify, clarify and focus busy charts using custom groups and segments.

Compilation of charts and tables before and after using custom fields with case statementsImage by author, April 2022

Using CASE expressions, you can:

  • Rebuild the labels used in your Google Ads account.
  • Group Google Ads campaigns by priority, targeted region, language, or theme.
  • Consolidate or customize default dimensions in your data source (such as swapping Google Analytics default channel grouping with Custom Channel Grouping).
  • Compare the performance of one keyword or asset against a group or category.

After learning some basic syntax and structure, you can create CASE expressions to solve your specific segmentation and classification challenges.

How To Use CASE Expressions In Data Studio

Looking for the step-by-step instructions for using Data Studio CASE expressions? Look no further.

Here we’ll review how to add a CASE statement and set up the formula.

1. Create A Calculated Field

You’ll find this option at the bottom right section of the Data Panel. Click the blue “Add a Field” button.

Image showing location of Screenshot taken by author, April 2022

2. Enter And Save The CASE Statement

Give your field a name, then enter the statement into the formula box (more on that below).

Screenshot of Screenshot taken by author, April 2022

A valid formula will show a small green arrow beneath the formula box.

Then hit “Save” (or “Update”) and “Done.” Skipping “Save” has the exact result you’d expect, so don’t forget to click both buttons.

3. Add The Field As A Dimension In Your Chart

You’ll find your new field containing the CASE statement in your list of Available Fields from the Data Panel, and you can add it as a dimension for your chart.

Location of dimension field in Data PanelScreenshot taken by author, April 2022

You can edit the CASE expression any time by clicking on it from the “Available Fields” section of the Data Panel.

How To Write Your CASE Statement

Now that you know how to add a CASE expression in Data Studio let’s look at the syntax you’ll use to build your formula.


You’ll use the following components in the formula box for your CASE statement:

  • CASE (opens the formula).
  • WHEN (describes the condition).
  • THEN (describes the result when the condition is met).
  • ELSE (optional: describes the result when the condition is not met).
  • END (closes the formula).

As you’ve already seen in this article, there are many ways to format a CASE statement.

Ultimately, you’ll want to find a “common denominator” that’s true only for the condition you’re defining with “WHEN.”

Here are some examples of how you could set up the WHEN / THEN formula:

  • WHEN [field] = “condition” THEN “result”
  • WHEN [field] != “condition” THEN “not result”
  • WHEN [field] IN (“Value A”, “Value B”, “Value C”) THEN “result”
  • WHEN REGEXP_MATCH ([field], “.*condition*”) THEN “result”
  • WHEN CONTAINS_TEXT ([field], “condition”) THEN “result”

You can get much more advanced than this, but it should be enough to get you started.

CASE Limitations And Caveats

With the great power of CASE comes the great responsibility of making sure your data is actually… accurate.

Here are some things to watch for and fix.

Aggregation Errors And Solution

Your data source and metric aggregation method can lead to inaccurate or broken charts, including:

  • Non-weighted average of an average: Averaging an average distorts actual performance metrics.
  • Avg. metric summing: Showing the total of an average is just wrong.
  • User configuration error: Some data sources will throw a configuration error instead of displaying improper aggregates.
Compilation image of potential errors using CASEImage by author, April 2022

Solution: Don’t aggregate pre-calculated fields.

If you have a metric that’s a calculation (CPC, AOV) rather than a raw total (Cost, Sessions), here’s what to do instead:

Create a new calculated field. Enter the formula, and swap the metric in your chart’s Data Panel with your new field.

New field screen showing cost / clicks formulaImage by author, April 2022

Segmentation Trap (Signal Vs. Noise)

There’s no limit to how you can slice and dice data, but there is a limit on how valuable some data segments will be.

Correlation is not causation, and identifying trends is not as valuable as knowing the cause.

So while you could segment your data by Avg CPC ranges, it’s the intent of the keyword, not the cost of the click, that drives post-click performance.

Be sure your segments relate to the effect shown in your chart, or you’ll find yourself optimizing for noise instead of signal.

Other Limitations

CASE has other constraints.

For instance:

  • CASE operates in sequential order. If a value meets the criteria for multiple categories, it will only be included in the first one listed in the CASE statement.
  • You can’t mix dimensions and metrics within a WHEN condition.
  • You can’t use a formula within a WHEN or THEN clause.
  • The CASE field you create is unique to the data source. If you need the same formula for multiple data sources, you’ll need to create new instances.

You’ll learn more about CASE by using it, but knowing the limitations means less time troubleshooting and searching help forums.


CASE statements are a powerful way to group and segment your data in Google Data Studio.

It’s not as simple as the drag-and-drop assembly you’re used to. But it’s also not out of reach.

Learn the basic rules and syntax, and before you know it, it’ll become a go-to tool in your visualizations toolbox.


More resources:

Featured Image: Billion Photos/Shutterstock

Source link


8 Pillar Page Examples to Get Inspired By



8 Pillar Page Examples to Get Inspired By

Pillar pages are high-level introductions to a topic. They then link to other pages, which are usually more detailed guides about parts of the main topic.

Altogether, they form a content hub.

Example of a content hub

But not all pillar pages look the same. 

In this guide, we’ll look at eight examples of pillar pages to get your creative juices flowing.

Excerpt of beginner's guide to SEO by Ahrefs

Key stats

Estimated organic traffic: 1,200
Backlinks: 6,900
Referring domains: 899

Overview of Ahrefs' beginner's guide to SEO in Ahrefs' Site Explorer

This is our very own pillar page, covering the broad topic of search engine optimization (SEO)

Why I like it

Besides the fact that I’m biased, I like the custom design we created for this page, which makes it different from the articles on our blog. 

Even though the design is custom, our pillar page is still a pretty classic “hub and spoke” style pillar page. We’ve broken the topic down neatly into six different chapters and internally linked to guides we’ve created about them. There are also custom animations when you hover over each chapter:

Examples of chapters in the SEO guide

We’ve also added a glossary section that comes with a custom illustration of the SERPs. We have explanations of what each element means, with internal links to more detailed content:

Custom illustration of the SERP

Finally, it links to another “pillar page”: our SEO glossary


Consider creating a custom design for your pillar page so that it stands out. 

Excerpt of Doctor Diet's ketogenic diet guide

Key stats

Estimated organic traffic: 92,200
Backlinks: 21,600
Referring domains: 1,700

Overview of Diet Doctor's ketogenic diet guide in Ahrefs' Site Explorer

Diet Doctor is a health company focusing on low-carb diets. Its pillar page is a comprehensive guide on the keto diet. 

Why I like it

On the surface, it doesn’t exactly look like a pillar page; it looks like every other post on the Diet Doctor site. But that’s perfectly fine. It’s simply a different approach—you don’t have to call out the fact that it’s a pillar page. 


Diet Doctor’s guide is split into 10 different sections with links to its own resources. The links bring you to different types of content (not just blog posts but videos too).

Video course about keto diet for beginners

Unlike the classic pillar page, Diet Doctor’s guide goes into enough detail for anyone who is casually researching the keto diet. But it also links to further resources for anyone who’s interested in doing additional research.


Pillar pages need not always just be text and links. Make it multimedia: You can add videos and images and even link to your own multimedia resources (e.g., a video course).

Excerpt of Wine Folly's beginner's guide to wine

Key stats

Estimated organic traffic: 5,600
Backlinks: 2,800
Referring domains: 247

Overview of Wine Folly's beginner's guide to wine in Ahrefs' Site Explorer

Wine Folly is a content site devoted to wine knowledge and appreciation. Its pillar page, as expected, is about wine. 

Why I like it

Wine Folly’s pillar page is a classic example of a “hub and spoke” style pillar page—split into multiple sections, with some supporting text, and then internal links to other resources that support each subsection. 

Supporting text and links to other resources

This page doesn’t just serve as a pillar page for ranking purposes, though. Given that it ranks well and receives quite a significant amount of search traffic, the page also has a call to action (CTA) to Wine Folly’s book:

Short description of book; below that, CTA encouraging site visitor to purchase it


While most websites design pillar pages for ranking, you can also use them for other purposes: capture email addresses, sell a book, pitch your product, etc. 

Excerpt of A-Z directory of yoga poses

Key stats

Estimated organic traffic: 11,100
Backlinks: 3,400
Referring domains: 457

Overview of Yoga Journal's A-Z directory of yoga poses in Ahrefs' Site Explorer

Yoga Journal is an online and offline magazine. Its pillar page is an A-Z directory of yoga poses.

Why I like it

Yoga Journal’s pillar page is straightforward and simple. List down all possible yoga poses (in both their English and Sanskrit names) in a table form and link to them. 

List of yoga poses in table form

Since it’s listed in alphabetical order, it’s useful for anyone who knows the name of a particular pose and is interested in learning more. 

What I also like is that Yoga Journal has added an extra column on the type of pose each yoga pose belongs to. If we click on any of the pose types, we’re directed to a category page where you can find similar kinds of poses: 

Examples of standing yoga poses (in grid format)


The A-Z format can be a good format for your pillar page if the broad topic you’re targeting fits the style (e.g., dance moves, freestyle football tricks, etc.).

Excerpt of Atlassian's guide to agile development

Key stats

Estimated organic traffic: 115,200
Backlinks: 3,200
Referring domains: 860

Overview of Atlassian's guide to agile development in Ahrefs' Site Explorer

Atlassian is a software company. You’ve probably heard of its products: Jira, Confluence, Trello, etc. Its pillar page is on agile development.

Why I like it

Atlassian’s pillar page is split into different topics related to agile development. It then has internal links to each topic—both as a sticky table of contents and card-style widgets after the introduction: 

Sticky table of contents
Card-style widgets

I also like the “Up next” feature at the bottom of the pillar page, which makes it seem like an online book rather than a page. 

Example of "Up next" feature


Consider adding a table of contents to your pillar page. 

Excerpt of Muscle and Strength's workout routines database

Key stats

Estimated organic traffic: 114,400
Backlinks: 2,900
Referring domains: 592

Overview of Muscle and Strength's workout routines database in Ahrefs' Site Explorer

Muscle and Strength’s pillar page is a massive database linking to various categories of workouts. 

Why I like it

Calling it a pillar page seems to be an understatement. Muscle and Strength’s free workouts page appears to be more like a website. 

When you open the page, you’ll see that it’s neatly split into multiple categories, such as “workouts for men,” “workouts for women,” “biceps,” “abs,” etc. 

Workout categories (in grid format)

Clicking through to any of them leads us to a category page containing all sorts of workouts:

Types of workouts for men (in grid format)

Compared to the other pillar pages on this list, where they’re linking to other subpages, Muscle and Strength’s pillar page links to other category pages, which then link to their subpages, i.e., its massive archive of free workouts.


Content databases, such as the one above, are a huge undertaking for a pillar page but can be worth it if the broad topic you’re targeting fits a format like this. Ideally, the topic should be about something where the content for it is ever-growing (e.g., workout plans, recipes, email templates, etc.).

Excerpt of Tofugu's guide to learning Japanese

Key stats

Estimated organic traffic: 39,100
Backlinks: 1,100
Referring domains: 308

Overview of Tofugu's guide to learning Japanese in Ahrefs' Site Explorer

Tofugu is a site about learning Japanese. And its pillar page is about, well, learning Japanese.

Why I like it

This is an incredible (and yes, ridiculously good) guide to learning Japanese from scratch. It covers every stage you’ll go through as a complete beginner—from knowing no Japanese to having intermediate proficiency in the language. 

Unlike other pillar pages where information is usually scarce and simply links out to further resources, this page holds nothing back. Under each section, there is great detail about what that section is, why it’s important, how it works, and even an estimated time of how long that stage takes to complete. 

Another interesting aspect is how Tofugu has structured its internal links as active CTAs. Rather than “Learn more” or “Read more,” it’s all about encouraging users to do a task and completing that stage. 

CTA encouraging user to head to the next task of learning to read hiragana


Two takeaways here:

  • Pillar pages can be ridiculously comprehensive. It depends on the topic you’re targeting and how competitive it is.
  • CTAs can be more exciting than merely just “Read more.”
Excerpt of Zapier's guide to working remotely

Key stats

Estimated organic traffic: 890
Backlinks: 4,100
Referring domains: 1,100

Overview of Zapier's guide to working remotely in Ahrefs' Site Explorer

Zapier allows users to connect multiple software products together via “zaps.” It’s a 100% remote company, and its pillar page is about remote work. 

Why I like it

Zapier’s pillar page is basically like Wine Folly’s pillar page. Break a topic into subsections, add a couple of links of text, and then add internal links to further resources. 

In the examples above, we’ve seen all sorts of execution for pillar pages. There are those with custom designs and others that are crazily comprehensive.

But sometimes, all a pillar page needs is a simple design with links. 


If you already have a bunch of existing content on your website, you can create a simple pillar page like this to organize your content for your readers. 


Keep learning

Inspired by these examples and want to create your own pillar page? Learn how to successfully do so with these two guides:

Any questions or comments? Let me know on Twitter.  

Source link

Continue Reading

Subscribe To our Newsletter
We promise not to spam you. Unsubscribe at any time.
Invalid email address