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.
The 4.0 and higher version of this page shows new LookML and the new LookML IDE. If you want to see the older user interface and its procedures, choose a pre-4.0 version in the upper right.
- Click Develop.
- Click the project you want to examine.
- Click the file you want to examine. Files with changes are marked with a green dot.
- View the code in that file. Lines with changes are highlighted on the edge in green.
- Expand the right sidebar to see explanations and options for the current location in the code. You can also click a parameter name in the sidebar to go to Looker documentation for that parameter.
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 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.
Structure and General Syntax
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
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:
+in the Models section.
- Name the model file and press return.
You can modify any model file by adding or removing explores, specifying joins, and adding other functionality.
Learning More About Parameters in Model 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 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.
Fields in Looker are split into dimensions and measures. A “dimension” can be one of two things:
- A column in your underlying table
- A computed value based on other fields
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
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:
- By creating a view from an existing database table
- By using a query in SQL*Runner to generat a view based on a derived table
- By creating a blank view file and manually creating the view
This article describes how to create view files using these alternative techniques.
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.
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.