Understanding model and view files

Stay organized with collections Save and categorize content based on your preferences.

This page provides an overview of model and view files, which are key components of most Looker projects. The other types of project files are described on the Understanding other project files documentation page. For information on accessing a project's files, see the Accessing and editing project information documentation page.

Model files

A model file specifies a database connection and the set of Explores that use that connection. A model file also defines the Explores themselves and their relationships to other views.

An Explore is a starting place for querying your data. In SQL terms, an Explore is the FROM clause of a query. The Explores you define in the model are seen by your users when they look at Looker's Explore menu. (See the How a project works in Looker documentation page for more information on Explores.)

In other words, the model file is where you define which data tables should be used (as included views) and how they should be joined together, if necessary.

Explores are usually defined within a model file. However, sometimes you need a separate Explore file for a derived table, or to extend or refine an Explore across models.

Structure and general syntax

Within an Explore's curly braces, { }, you define parameters for the Explore. You can use join parameters to join other views to an Explore in a model file.

Above we see the explore called inventory_items in the model file, along with its joined views. This LookML definition causes Inventory Items to appear in the Explore menu, and joins data from inventory_items to products and distribution_centers.

For more specific information on the LookML structures in a model file, see the LookML terms and concepts documentation page.

Creating model files

Most LookML developers start with one or more model files that are created automatically when the LookML project is generated from a set of tables in a database.

Alternatively, a Looker developer in Development Mode can create a blank model file in the following ways:

You can modify any model file by adding or removing Explores, specifying joins, and adding other functionality.

If you need to rename a model or any object in the model, do not rename the file or the object itself. Instead, use the label or alias parameter to change the displayed name of the file or object. The label and alias parameters change the displayed name while preserving the underlying URL used for emails or other systems.

In general, you should take precautions to make model changes as noninvasive as possible. If you do need to rename a model or an object, use the Content Validator to update all references to the model or object.

If you delete a model file, the model is not removed from any model sets to which the model belonged. If a new model file is created with the same name as a deleted model, the new model is included in any model sets that included the deleted model. This can result in giving unwanted access to the new model file. Looker admins can edit model sets and remove a deleted model to prevent this issue.

Learning more about parameters in model files

Read the Model parameters, Explore parameters, and Join parameters documentation pages to learn more about LookML parameters in the model file.

View files

A view file generally defines a single "view" within Looker. A view corresponds to either a single table in your database or a single derived table.

The view file specifies a table to query and the fields (dimensions and measures) to include from that table.

Structure and general syntax

Within each view's curly braces, { }, are field definitions, which usually correspond to a column in the underlying table or a calculation in Looker. Looker categorizes most of them as either dimensions or measures.

Above we see the dimension id defined as a field in the Order Items view. This definition exposes the ID field for queries in the Order Items Explore.

You can also create several time-based dimensions at once using dimension groups or specify a filter for your users with filter fields. Check out the View parameters documentation page to learn more about LookML parameters in view files.

For more specific information on the LookML structures in a view file, see the LookML terms and concepts documentation page.


Fields in Looker are split into dimensions and measures. A dimension can be one of two things:

  • A column in your underlying table
dimension: first_name {
  sql: ${TABLE}.first_name ;;
  • A computed value based on other fields
dimension: full_name {
  sql: CONCAT(${first_name}, ' ', ${last_name}) ;;

In Looker, dimensions always appear in the GROUP BY clause of the SQL that Looker generates.

In LookML, you can define different dimension types that correspond to different data types or formatting.


A measure computes values across multiple rows. This is equivalent to SQL aggregate functions like COUNT(), SUM(), AVG(), MIN() and MAX(). Measures can also perform simple transformations on other measures. Check out our measure types documentation to learn more.

Above we can see dimensions and measures defined in the products view file.

Creating view files

Most LookML developers start with one or more view files that are created automatically when the LookML project is generated from a set of tables in a database. However, there are many ways a Looker developer in Development Mode can add view files to a LookML project:

To use a new view, add it to your model file using the explore parameter, or use the join parameter to join it to an existing Explore in your model file.

Adding a new view from an existing database table

You can create a view file from an existing database table while in Development Mode.

  1. Within a project, click + at the top of the project file list in the Looker IDE, or you can click a folder's menu to create the file inside the folder.

  2. Click Create View From Table.

  3. Looker displays a list of tables associated with one of your connections. To change the connection, use the Connection drop-down in the upper left.

  4. Select any tables that you would like to create views from by checking the box to the left of the table name. You can collapse and expand databases or schemas in this list to access all available tables.

  5. Scroll to the bottom of the page and click Create Views.

  6. Looker generates views containing LookML for all the table columns.

Learning more about parameters in view files

You can learn more about view parameters on the View parameters documentation page.

Read more about LookML parameters for dimensions, measures, dimension groups, and filter fields on the Field parameters documentation page.