How to Do Combined Total on Looker

Cody Schneider8 min read

Calculating a combined total in Looker seems like it should be straightforward, but it can quickly become a multi-step process. Whether you're trying to add two different revenue streams together or create a single grand total from multiple measures, it’s not always as simple as clicking a "sum" button. This guide will walk you through the most effective methods for creating combined totals in Looker using both Table Calculations for quick analysis and LookML for creating permanent, reusable metrics.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why a "Combined Total" Isn't Just a Regular Total

First, let's clarify the difference. Looker’s built-in "Totals" feature is excellent for summing a single measure. If you have a "Total Sales" column, you can toggle on "Totals" to see a summary row for that specific column at the bottom of your table. Easy.

A "combined total," however, involves arithmetic across multiple different measures. Imagine an e-commerce dashboard. You might have separate measures for:

  • Product Revenue
  • Shipping Revenue
  • Tax Revenue

A simple column total won't give you a single "Gross Revenue" figure. You need to actively add these measures together, either on-the-fly for a quick report or by creating a new, permanent field for everyone on your team to use. We'll cover both scenarios.

Method 1: Using Table Calculations for Quick, Ad-Hoc Totals

Table Calculations are your best friend for quick analysis. They perform calculations on the data already returned in your Explore, which means you can create new columns without needing to ask a developer to change the underlying code. This is perfect for when you need a one-off combined figure for a specific report.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step-by-Step: Creating a Combined Total with Table Calculations

Let’s use an example. Imagine you have a report showing daily sales and want to combine Order Item Subtotal and Tax into a Total Daily Revenue column.

1. Build Your Initial Report: Start in your Looker Explore. Select your dimension (e.g., "Created Date") and the measures you want to combine (e.g., "Order Item Subtotal," "Tax"). Run the query to generate your base table.

2. Open Table Calculations: In the data table, click the "Calculations" button. This will open the Table Calculation editor.

3. Write the Combination Formula: The editor lets you use spreadsheet-like formulas. The syntax to reference a field is ${view_name.field_name}. To add our two measures, the formula is simple:

${order_items.total_subtotal} + ${order_items.total_tax}

4. Format and Name Your Calculation: Give your new column a clear name in the "Title" field, like "Total Daily Revenue." You can also choose a number format, such as "Currency."

5. Save and See the Result: Click "Save." A brand new column, "Total Daily Revenue," will appear in your table, showing the sum of the other two measures for each row. You've just created a row-level combined total!

Getting a Single Grand Combined Total (The "KPI" Number)

But what if you don't need a new column? What if you just want a single, big number showing the grand total of everything combined? The process is slightly different.

  1. First, combine the original measures: Follow the steps above to create your row-level combined total column (e.g., "Total Daily Revenue").
  2. Next, sum the new calculated column: Create a second Table Calculation. This time, your formula will sum the column you just made:

sum(${total_daily_revenue})

  1. Finally, visualize it: Go to the "Visualization" tab and choose the "Single Value" chart type. Now, in the data table, hide every column from the visualization except your final summarized calculation. The result is a clean, single number representing your grand combined total.

This is a great technique for building KPIs for a dashboard without having to change any LookML.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Method 2: Building a Permanent Combined Total with LookML

While Table Calculations are fast and flexible, they have a major limitation: they only exist for you, in your current Explore. If your "Total Revenue" is a core business metric that everyone needs to use consistently, you should build it into your LookML model.

This approach defines the combined total at the data model level, making it a permanent, governed, and reusable field that anyone in your organization can drag and drop into their reports, just like any other measure.

Heads Up: This method requires LookML developer permissions.

Step-by-Step: Creating a 'measure' for a Combined Total

Sticking with our Subtotal + Tax example, here’s how to build it in LookML.

1. Enter Development Mode & Find the Right View File: Navigate to your project, enter Development Mode, and go to the LookML view file where your base measures (like total_subtotal and total_tax) are defined. In most cases, this would be a file named something like order_items.view.lkml.

2. Define a New measure: Scroll to the measures section of the file and add a new block of code. This code will create a new measure called total_revenue.

Here’s the LookML code you'd write:

measure: total_revenue { type: sum label: "Total Revenue" value_format_name: usd sql: ${TABLE}.subtotal + ${TABLE}.tax ,, description: "Total revenue including subtotal and tax. For official gross revenue reporting." }

Breaking Down the Code:

  • measure: total_revenue: This is the machine-readable name of your new field.
  • type: sum: This tells Looker how to aggregate the numbers. Because our SQL is already performed row-by-row, sum simply adds up all the results.
  • label: "Total Revenue": This is the user-friendly name that will show up in the Explore UI for business users.
  • value_format_name: usd: This formats the number as currency. You could use other formats like decimal_2 or percent_0.
  • sql: ${TABLE}.subtotal + ${TABLE}.tax ,,: This is the core logic. It's the physical SQL code that the database will run. It finds the subtotal and tax columns in the order_items table and adds them together for each row before Looker does any aggregation.
  • description: A best-practice addition. This text appears when a user hovers over the field in the Explore, explaining exactly what the metric represents.

3. Save, Validate, and Deploy: Save your changes to the LookML file, validate your code using the LookML Validator to check for errors, and then deploy your changes to production. Now, the "Total Revenue" measure will appear as a permanent field in the Order Items Explore for all users.

Table Calculations vs. LookML: Which Method Should You Use?

Use Table Calculations when:

  • You’re Exploring: You have a hypothesis and want to quickly test a new metric without changing the permanent data model.
  • You Lack Permissions: You aren't a LookML developer and can't make backstage changes.
  • It’s a One-Time Need: You need a specific combined figure for a single report or presentation and likely won't need it again.

Use LookML when:

  • It’s a Core Metric: The combined number (e.g., Gross Revenue, Total Marketing Spend) is a key performance indicator referenced by multiple people.
  • You Need Consistency: You want to ensure everyone in the company calculates the metric the exact same way every time. Defining it in LookML creates a single source of truth.
  • You Want Better Performance: For huge datasets, pushing the calculation down to the database with SQL is often more performant than running it in the browser with Table Calculations.
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Tips and Common Mistakes to Avoid

Here are a few pointers to save you some time and frustration.

1. Watch for NULLs: A common pitfall occurs when one of the values you’re adding is NULL (empty). In SQL, 5 + NULL = NULL. This can cause your totals to be unexpectedly blank. To fix this in LookML, use the COALESCE function to treat any null values as zero.

An improved LookML sql parameter would be:

sql: COALESCE(${TABLE}.subtotal, 0) + COALESCE(${TABLE}.tax, 0) ,,

2. Check Your Data Types: Ensure the fields you're adding are both numeric types. You can't add a number to a string of text. Looker is generally good at handling this, but type mismatch errors can still pop up.

3. Use a Descriptive label: In LookML, a clear label is your gift to future you and the rest of your team. label: "Total Item Revenue (incl. Tax)" is far better than a default name, as it explains what's included in the calculation without anyone having to guess.

Final Thoughts

Creating combined totals in Looker is completely achievable once you know where to look. By mastering both temporary Table Calculations for personal analysis and permanent LookML measures for official business metrics, you can get a complete and accurate picture of your data, all within one platform.

At the same time, mastering Looker takes considerable time, and writing formula logic, even simple sums, adds an extra layer of complexity. Here at Graphed, we're building a world where you don’t need to be an expert to get answers. Instead of digging through menus to create table calculations or writing LookML, you can simply ask a question in plain English, like "show me our total revenue from products and tax last quarter," and instantly get back a real-time dashboard with the right charts, no setup required.

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!