Understanding Model and View Files

LookML
Version

On this Page
Docs Menu

This article 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 LookML Files

You can access LookML files by going to the LookML 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.

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

  1. Click Develop (or “LookML”, depending upon your version).
  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 changes are highlighted on the edge in green.

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

  • Click the Looker icon that appears to the left of the field name:

  • Click Go to LookML from the gear drop down menu for a field:

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. Explores defined in the model file appear in the explore menu in Looker.

Indented under an explore, 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.

Check out 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.

Within each view 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:

  • A column in your underlying table

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

  • A computed value based on other fields

- dimension: full_name sql: CONCAT(${first_name}, ' ', ${last_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.

Read more about LookML parameters for dimensions in the Field Parameters Reference.

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.

LookML Dashboard Files

Looker Dashboard files enable you to combine key queries and visualizations into a one page executive view stored as version-controlled files associated with the project. LookML Dashboards are created using old LookML as described on this page.

Looker also has User-defined Dashboards, which can be created by non-developer users without LookML coding. For details, refer to Building Dashboards.

Still have questions?
Go to Discourse - or - Email Support
Top