How to Create a View in Looker
Creating a View is the first and most fundamental step to analyzing your data in Looker. Views are the building blocks that translate your raw database tables into the interactive fields your team will use to build reports and uncover insights. This tutorial will walk you through exactly what Views are, how to create them from scratch, and some best practices for making them user-friendly.
What is a Looker View?
In Looker, a view is a file that defines the dimensions and measures for a specific dataset. Think of it as a dictionary or a lens for one of your database tables (like users, orders, or products). The view file doesn’t contain the data itself, it just contains the LookML (Looker Modeling Language) code that tells Looker how to interact with your data tables.
Each view typically corresponds to a single table in your database or a "derived table" that you define with SQL. Inside a view file, you’ll define two key components:
- Dimensions: These are your groupable fields - the "by" in your analysis. They represent columns in your data like
user_id,created_date,city, orproduct_category. Dimensions are used for filtering, grouping, and segmenting data. - Measures: These are your aggregated fields, performing calculations on a set of data. Think of things like
COUNT(users),SUM(revenue), orAVERAGE(order_value). Measures are how you quantify performance.
Together, views, models, and explores form the core of a LookML project. A view defines the fields. An explore makes a view queryable and defines join relationships between views. A model defines the database connection and brings together the explores that should be exposed to users.
Before You Start: Prerequisites
Before you jump into creating a view, make sure you have the following in place:
- You are in Development Mode: You can only make LookML changes when your instance is in dev mode. You can toggle this on a banner at the top of your Looker screen.
- You have
developpermissions: Your Looker admin needs to grant you a permission set that includes thedeveloppermission to allow you to edit LookML. - You have a configured database connection: Your Looker instance needs to be successfully connected to the database you want to pull data from.
- Knowledge of your data schema: Know which table you want to create a view from. For example, if you want to analyze orders, you should know the table is named
ordersand contains columns likeorder_idandamount.
Method 1: Creating a View from an Existing Database Table
The most common way to create a view is by pointing Looker directly at a table that already exists in your database. Looker’s generator can do a lot of the initial work for you, creating dimensions for every column in the table.
Step 1: Go to Your LookML Project
Navigate to the Develop section in the main Looker menu and select the LookML project you're working in.
Step 2: Start Creating the View File
Once you’re in your project, find the file browser on the left-hand side. Click the + icon at the top and select "Create View" from the dropdown menu.
Step 3: Generate the View from a Table
A pop-up will appear. At the bottom, you'll see a blue link that says "Create View From Table." Click it. You will then be prompted to select a database table from a dropdown list. Find and select the table you want (e.g., orders) and Looker will automatically generate a new view file with the same name.
The file will be pre-populated with LookML code that looks something like this:
view: orders {
sql_table_name: `public.orders` ,,
dimension: order_id {
primary_key: yes
type: number
sql: ${TABLE}.order_id ,,
}
dimension: status {
type: string
sql: ${TABLE}.status ,,
}
dimension_group: created {
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.created_at ,,
}
dimension: amount {
type: number
sql: ${TABLE}.amount ,,
}
measure: count {
type: count
drill_fields: [order_id]
}
}Step 4: Understand and Refine the Automatically Generated LookML
The generator gets you started, but you'll almost always need to customize it. Here's what was created:
sql_table_name:points to the actual table in your database schema (public.orders).dimension:Looker creates a dimension for each column in your table (likeorder_id,status,amount).dimension_group:For timestamp columns (likecreated_at), Looker intelligently creates a dimension group, which automatically generates dimensions for different timeframes (date, week, month, etc.). This is hugely convenient!measure: count:By default, Looker adds a simple count measure to get you started. This counts the total number of rows.
Your job now is to improve this file. For example, you’ll want to add more useful measures. If you have an amount dimension, you almost certainly want to see the total sum. You can add a new measure like this:
measure: total_amount {
type: sum
sql: ${amount} ,,
}Notice we reference the dimension by typing ${amount} instead of the raw SQL ${TABLE}.amount. This is a best practice, as it lets you reuse the logic defined in your dimension.
Method 2: Creating a Derived Table View
Sometimes the data you need doesn’t exist neatly in a single table. You might need to pre-aggregate data, pivot values, or join tables together before you can analyze them. For this, you use a derived table.
A derived table is a view based on a query you write, rather than a direct table in your database. Looker treats the results of that query as if it were a physical table.
Let's create a view that summarizes lifetime value for each customer. For this, we need to calculate total orders and total revenue per user from our orders table.
Step 1: Create a New, Blank View File
In the file browser, click the + icon and choose "Create View" again. This time, instead of selecting from a table, simply give your new view a name (e.g., user_order_summary) and click "Create." Looker will make an empty view file for you.
Step 2: Define Your Derived Table with a SQL Query
Inside the empty view: {} block, add the derived_table parameter. Inside that, you'll add a sql parameter containing your query. This query should calculate everything you need.
view: user_order_summary {
derived_table: {
sql: SELECT
user_id,
COUNT(DISTINCT order_id) AS lifetime_orders,
SUM(amount) AS lifetime_value
FROM
public.orders
GROUP BY
1
,,
}
# Dimensions and measures go here
}Step 3: Define Dimensions and Measures for Your Table
Now, you must define dimensions and measures that correspond to the columns in your SELECT statement. The process is the same as before, but the source of the data is your query's result set, not a raw table.
view: user_order_summary {
derived_table: {
# ... SQL query from above ...
}
dimension: user_id {
primary_key: yes
type: number
sql: ${TABLE}.user_id ,,
}
dimension: lifetime_orders {
type: number
sql: ${TABLE}.lifetime_orders ,,
}
dimension: lifetime_value {
type: number
sql: ${TABLE}.lifetime_value ,,
value_format_name: usd_2
}
measure: total_customers {
type: count_distinct
sql: ${user_id} ,,
}
}Now you have a brand-new view based on an aggregation of your orders data, which you can join back to other views like users to provide powerful context.
Best Practices for Creating Clean Views
Simply creating a functional view is one thing, creating a user-friendly view is another. Follow these tips to make life easier for your business users who will be using your fields in Explores.
- Add Descriptions: Use the
description:parameter on views, dimensions, and measures. These descriptions appear as tooltips in the Explore interface, providing crucial context for users. - Use Labels: If a database column has a messy name like
_prod_ord_sts, you can use thelabel:parameter to give it a clean, human-readable name like "Order Status." - Format Your Data: Use
value_format_name:orvalue_format:to make numbers more readable. You can apply formats for currency (usd_0), percentages (percent_2), or custom formats like#,##0. - Group Fields Logically: If your view contains dozens of fields, the Explore UI can get cluttered. Use the
group_label:parameter to cluster related fields together under a single collapsible heading (e.g., "User Details," "Order Metrics"). - Hide Unnecessary Fields: Use
hidden: yeson fields like foreign keys or intermediate calculation steps that users don't need to see in the Explore UI. This cleans up the field picker and prevents confusion.
Next Step: Add Your View to an Explore
A view isn't usable until it’s been included in your model file as part of an explore. An explore makes the view's fields available for querying in the main Looker interface. In your model file (e.g., my_project.model.lkml), you can add the view like this:
explore: orders {}This simple declaration exposes the orders view as a starting point for exploration. From there, you can define joins to connect this view with others, building out a comprehensive analytical model for your team.
Final Thoughts
Views are the foundational components of any LookML project, translating raw database tables into a user-friendly data dictionary of dimensions and measures. Whether you’re generating them directly from tables or crafting custom derived tables, mastering views is an essential skill for anyone developing in Looker.
While Looker is a powerfully expressive tool for data modeling, it has a steep learning curve and requires expertise in LookML to get started. For marketing and sales teams who just need answers quickly, the hurdles of modeling can be a blocker. We built Graphed to remove that friction, allowing you to connect sources like Google Analytics, Salesforce, and Facebook Ads and then create dashboards just by asking. You can get from data to decision in seconds instead of spending hours coding.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?