How to Remove Null Values in Looker
Nothing ruins a clean Looker dashboard faster than 'null' values. They show up as gaps in your charts, skew your calculations, and can make your otherwise insightful reports look broken. The good news is that you don't have to live with them. This tutorial will walk you through several practical methods for removing or replacing null values in Looker, from quick cosmetic fixes to robust back-end solutions.
What Are Null Values and Why Do They Matter?
In the world of data, a 'null' value signifies the absence of data. It's an empty cell. It’s important to understand that null is not the same as zero (0) or a blank text string (""). Zero is a specific numerical value, while a blank string is a character value - 'null' is a placeholder for something that simply isn't there.
Think about a table of customer orders. If the return_date column is null, it means the item hasn't been returned. If the discount_code column is null, it means no discount was applied. These are valid and useful nulls. But what if the order_total is null? That’s a bigger problem.
Here's why you need to manage them:
- They Skew Calculations: Calculating the average order value from a column containing nulls might result in only considering orders with values, leading to skewed averages.
- They Break Visualizations: In line charts, a null value can disrupt the flow of the visualization and appear unprofessional in tables.
- They Cause Logical Errors: Nulls don't behave predictably when creating filters or custom logic, potentially excluding rows unintentionally.
Learning how to handle these empty values properly is a core skill for anyone who works with data. So, let’s explore the best ways to do it directly within Looker.
Method 1: The Quick Fix - Hiding Nulls in a Visualization
Sometimes, you just need to clean up a single chart for a presentation. The null values might be valid in your data set, but they're making your graph look strange. In this case, Looker’s visualization settings are your best friend.
This approach hides the null values from view in that specific visualization but doesn't filter them out of the underlying data. This means your calculations will still be affected. This is best for cosmetic changes.
Let's say you have a line chart showing sales over time, but a few dates have null sales, creating gaps in your line.
- Run your Explore to get your data and select your visualization type (e.g., Line Chart).
- Click the gear icon in the top right of the visualization panel to open the settings.
- Navigate to the Plot tab.
- Look for the setting called Null Value Display. You'll often see options like 'Disconnected' (the default) or 'Render as Zero'. Choosing 'Render as Zero' can visually fill the gap.
- For many charts, you may also want to go to the Y tab and uncheck the Unpin from Zero option. This can help normalize the axis when dealing with missing values.
When to use this method: It’s perfect for a quick, one-off visual adjustment when you need a chart to look clean for a report or dashboard, and you understand that the underlying calculations are not changed.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Method 2: Handling Nulls Directly in an Explore
If you want more control over the data before it gets to the visualization, you can handle nulls in the Explore section itself. This gives you two great options: filtering the nulls out completely or replacing them with a different value.
Using Filters to Exclude Null Rows
The most direct way to remove nulls from your query results is to filter them out. This tells Looker to exclude any row where your specified field is empty.
Let's say you're analyzing user sessions but want to exclude any sessions that don't have a known traffic source.
- In your Explore's Filter section, select the dimension you want to filter (e.g.,
Traffic Source). - In the filter conditions dropdown, choose is not null.
- Click Run.
That's it. Looker will now add a WHERE traffic_source IS NOT NULL clause to the SQL query it generates, removing those rows from your results entirely.
Alternatively, you can create a Custom Filter for more complex logic. In the custom filter field, you can write:
NOT is_null(${traffic_source.name})When to use this method: Use filters when null values represent irrelevant or “bad” data that you want to completely exclude from both the visualization and the calculations in your current analysis.
Using Table Calculations to Replace Null Values
Sometimes you don't want to remove a whole row just because one field is null. Instead, you'll want to replace the null with something more meaningful, like a zero or "N/A". This is a perfect job for table calculations.
Table calculations run after the main query finishes, letting you perform Excel-like operations on your results table.
Imagine you have a table showing revenue, but some of the revenue figures are null. You want to treat those as zero for a new "Adjusted Revenue" column.
- In the Data section of your Explore, click + Add calculation.
- Give your new column a name, like "Adjusted Revenue".
- Use the
if()andis_null()functions in the formula area. The logic is: "if the value in the revenue column is null, then output 0, otherwise, use the original revenue value."
The formula would look like this:
if(is_null(${orders.revenue}), 0, ${orders.revenue})- Choose your desired formatting and hit Save.
You now have a new column in your results that you can use in visualizations, and the original column remains untouched.
When to use this method: Table calculations are ideal when you want to replace nulls on the fly for a specific analysis without needing developer help. It's flexible and lets you see the impact of replacing nulls immediately.
Method 3: The Developer’s Approach - Building Solutions in LookML
For a permanent, scalable fix that applies to everyone in your organization, the best place to handle nulls is in the LookML model. This ensures consistency and saves everyone from having to 'reinvent the wheel' with filters and table calculations every time. This generally requires Looker developer permissions.
Applying a Permanent Filter with sql_always_where
If you know that null values in a certain field should almost always be excluded from analysis, you can build this logic directly into the Explore's definition using sql_always_where.
For example, if you want your 'Orders' Explore to always exclude any orders where the price is null, a LookML developer would add this to the explore definition:
explore: orders {
sql_always_where: ${orders.sale_price} IS NOT NULL ,,
}Now, any user who loads this Explore will automatically have that filter applied. They can still add more filters on top of it, but this base condition will always be there, preventing bad data from ever reaching end-users.
When to use this method: Use this when a specific filter condition is a fundamental business rule that should apply to virtually all analyses using that Explore.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Creating a New Dimension with COALESCE
This is arguably the most robust and flexible LookML method. Instead of filtering rows out, you create an alternative, "cleaned" version of a dimension where nulls are replaced. The most common SQL function for this is COALESCE.
The COALESCE(value1, value2, ...) function returns the first non-null value it finds in the list you provide. This is perfect for replacing nulls with a default fallback value.
Imagine the same revenue scenario. A developer can open the orders.view file and create a new dimension:
dimension: revenue_adjusted {
type: number
label: "Adjusted Revenue (Nulls as 0)"
sql: COALESCE(${TABLE}.revenue, 0) ,,
}Now, users will see two fields in the Explore: 'Revenue' (the original, which might contain nulls) and 'Adjusted Revenue (Nulls as 0)' (which never contains nulls). They can choose which one is more appropriate for their analysis. This gives users both power and a clean, governed field to rely on.
When to use this method: This is the gold standard for promoting data consistency. It creates durable, reusable, and clearly named fields for your whole team, while preserving the raw, original data for auditing or specific use cases.
Final Thoughts
Handling null values effectively is a sign of a high-functioning data culture. Whether you're doing a quick visual hide in the plot menu, applying a one-time filter or table calculation in an Explore, or creating a permanent solution with LookML, Looker gives you the tools you need at every level. Choosing the right method depends on whether your goal is a quick fix, a flexible personal analysis, or a permanent, scalable change for your entire organization.
While Looker provides the Lego blocks to build these solutions, it often requires navigating menus, writing LookML, or remembering the right formulas. At a certain point, the data wrangling gets in the way of getting answers. We believe this process should be as simple as asking a question. With Graphed, you can simply connect your data sources and ask questions in plain English, like "show me last month’s sales by traffic source, but ignore sessions without revenue". Instead of building filters or writing code, you get the right chart instantly, freeing you up to focus on the insights, not just the setup.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.