User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
Understanding Model and View Files

This page discusses accessing project files and provides an overview of the basic components of a data model in LookML. You’ll learn the structure of your model and view files, giving you a foundation for designing and developing your own customizations.

Accessing Project Files

You can access project files by going to the Develop navigation menu and selecting the project you would like to view. This will take you to the LookML file browser page. The file browser in Looker groups files by type: Documentation, Model, View, Dashboard, or Data.

Note: You must be in development mode in order to edit files.

  1. Click Develop.
  2. Click the project you want to examine.
  3. Click the file you want to examine. Files with changes are marked with a green dot.
  4. View the code in that file. Lines with additions or changes are highlighted on the edge in green; lines that have been deleted are marked with a red dotted line in the margin. These change markers are displayed until the changes are committed.
  5. Expand the right sidebar to see explanations and options for the current location in the code. You also can click a parameter name in the sidebar to go to Looker documentation for that parameter.

Searching for Project Files

Looker provides an integrated development environment (IDE) for creating and managing your project files. The IDE is often referred to as the LookML editor as that’s where you edit LookML files.

In the Looker IDE, you can search for and open a project file using a keyboard shortcut described in the Keyboard Shortcuts documentation page. Open the search window using the keyboard shortcut Command-J (Mac) or Ctrl+J (Windows):

  1. In the Jump to file field, enter a search term. The search term can be a word or any part of a word.
  2. The file list will show only those files that include your search term. The results show each file’s name and file type. Click the file you want to open.

Accessing LookML from an Explore

You can also directly access the LookML for an Explore or a field from an Explore. This can be done in several ways:

After selecting a field, you will be taken directly to the field definition in the corresponding view file.

Model Files

Model files define Explores 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.

You typically define your Explore in a model file. However, if you have defined a native derived table (NDT), then you should define an Explore in an Explore file (explore_filename.explore.lkml). Explore files are stored in the Other category in the IDE.

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 order_items Explore in the model file, along with its joined views. This LookML definition causes “Order Items” to appear in the Explore menu, and joins data from order_items to inventory_items and user.

Creating Model Files

Most LookML developers start with one or more model files created by generating from a set of tables in a database.

Alternatively, a blank model file can be created in Development Mode:

  1. Click + next to Add Files.
  2. Click Create Model.
  3. Name the model file and press return.

You can also drag a file with the extension .model.lkml into the LookML IDE, which adds the file into the Models section.

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.

Learning More About Parameters in Model Files

Read the Model Reference, Explore Reference and Join Reference 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.

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 “ORDER ITEMS 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 Reference to learn more about LookML parameters in view files.

Dimensions

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

dimension: first_name { sql: ${TABLE}.first_name ;; }

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.

Measures

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 created by generating from a set of tables in a database.

Alternatively, a new view file can be created:

This Community topic describes how to create view files using these alternative techniques.

You can also drag a file with the extension .view.lkml into the LookML IDE, which adds the file into the Models section.

Learning More About Parameters in View Files

You can learn more about view parameters in the View Parameters Reference.

Read more about LookML parameters for dimensions, measures, dimension groups, and filter fields in the Field Parameters Reference.

Top