User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
  
English
Français
Deutsch
日本語
include

Usage

include: "*.view"

Hierarchy

include

- or -

include

Default Value

None

Accepts

A string containing a file name or pattern

Definition

New in Looker 6.16, the Looker IDE supports folders to help you organize your LookML project files. If your project has IDE folders enabled, you must specify the file’s path in the include parameter. See this documentation page for information on using include with IDE folders.

The include parameter specifies the LookML files that will be available to a model, a view, or an Explore. If you want to use or reference a LookML file within another file, you must add it with the include parameter.

You can use the include parameter in model files, view files, and Explore files. The include parameter can reference different types of LookML files, depending on the context.

In a model file, you can use include to reference:

In a view file, you can use include to reference:

In an Explore file, you can use include to reference:

You can also use include to bring in files from other projects. See this documentation page for information on including files from another project. To import files from local LookML projects, you must enable the Local Project Import Labs feature.

Note the following when using include:

Handy Tip: When using wildcards, you can check which files are included by hovering over the information icon in the change bar of the file, or by clicking on the include statement and looking in the Quick Help:

Using include in a Model File

You can use the include parameter in a model file to include views and dashboards, other models, or Explores.

Including Views and Dashboards in a Model

Use the include parameter in a model file to specify the dashboard and view files that will be available to that model. If you want to use or reference a LookML file within a model, you must add it with the include parameter.

In the include parameter, use the extension .view for view files and the extension .dashboard for dashboards. You can leave out the .lkml and .lookml part of these extensions.

You can use the * wildcard character to indicate files with strategic naming conventions or with the same extension.

In the example below, these include parameters in a model file will indicate:

include: "*.dashboard" include: "*base.view.lkml"

If your project has a large number of view files or if your project uses persistent derived tables (PDTs), you should avoid including all view files in your model. Instead, include individual view files like this:

include: "order.view" include: "user.view" include: "*.dashboard"

Including Models in a Model

In a model file, you can use include to reference another model file within the same project.

Chat Team Tip: If you are including models in other models in order to extend an Explore across models, a better method is to create a separate Explore file to use as a base file. Once you have defined the base Explore in its own file, you can include the Explore file in your model file and extend the Explore in your model file.

In the include parameter, use the extension .model.lkml for model files.

When you include one model in another model file, the database connection must be specified only in the included model file.

For example, here is the all_users model file with a connection and an Explore defined:

connection: "faa" include: "accidents.view" explore: accidents { view_name: accidents from: accidents extension: required }

The all_users model file has a database connection defined, and has included the accidents.view file. It also has an Explore defined that requires extension.

You can now include the all_users model file in another model file to extend the accidents Explore. Here is another model file called external_users that includes the all_users model file and extends the accidents Explore:

include: "all_users.model.lkml" explore: accidents_external { extends: [accidents] fields: [accidents.event_id,accidents.airport_code,accidents.count] }

In the external_users file you don’t have to specify a connection, nor do you have to include the accidents.view file. That information is carried over when we include the all_users model file.

Including Explores in a Model

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

If you do have a separate Explore file, you need to use the include parameter in the model file to include it. In the include parameter, use the extension .explore.lkml for Explore files.

For example, below is a model file that has two Explores:

connection: "faa" include: "aircraft_new.explore.lkml" include: "accidents.view" explore: accidents { view_name: accidents from: accidents }

Using include in a View File

For the most part, you don’t need to use include in a view file. However, there are some cases in which you do want to include files in your view file:

Including Views in a View (to Reference Fields)

You can include a view file in another view file to reference fields from the other view.

In the include parameter, use the extension .view when including view files. You can leave out the .lkml part of the file extension.

For example, here is an orders view file that includes the inventory view file and uses a reference to an inventory field:

include: "inventory.view" view: orders { dimension: profit { type: number sql: ${sale_price} - ${inventory.cost} # The file that contains the inventory } # view should be included }

Including Views in a View (to Extend)

You can also include a view file in another view file to complete an extension.

For example, here is the marketing_order_fields view file that includes the basic_order_fields view file and then extends it:

include: "basic_order_fields.view" view: marketing_order_fields { extends: [basic_order_fields] # The file that contains the basic_order_fields } # view should be included

Including Explores in a View

In most cases, you don’t need to include an Explore in a view. However, native derived tables (NDTs) are a special case because they are defined in their own view file that has an explore_source parameter. You use the explore_source parameter to specify an Explore and define the desired columns and other desired characteristics for the NDT. Explores are usually defined within a model file, but in the case of NDTs it may be cleaner to create a separate file for the Explore using the .explore.lkml file extension. If you create a separate Explore file, you must include the Explore file in the NDT view file.

Here is an example of using include in a NDT view file to point to an Explore file:

include: "order_items.explore.lkml" view: user_order_facts { derived_table: { explore_source: order_items { column: user_id {field: order_items.user_id} column: lifetime_number_of_orders {field: order_items.order_count} column: lifetime_customer_value {field: order_items.total_revenue} derived_column: average_customer_order { sql: lifetime_customer_value / lifetime_number_of_orders ;; } } } dimension: user_id {hidden: yes} dimension: lifetime_number_of_orders {type: number} dimension: lifetime_customer_value {type: number} dimension: average_customer_order {type: number} }

See this documentation page for more information on Explore files for NDTs.

Using include in an Explore File

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

If you do have a separate Explore file, you can use the include parameter to include views or other Explores.

Including Views in an Explore

If you have a separate Explore file, you need to include any views that are used by the Explore. Use the file extension .view for view files. You can leave out the .lkml part of the file extension. Here is an example Explore file that includes the two views it’s using:

include: "aircraft.view" include: "aircraft_types.view" explore: aircraft { join: aircraft_types { type: left_outer sql_on: ${aircraft.aircraft_type_id} = ${aircraft_types.aircraft_type_id} ;; relationship: many_to_one } }

Including Explores in an Explore

You can include one Explore file in another Explore file, such as when you are extending an Explore. Use the include parameter and add the file extension .explore.lkml.

Here is an example Explore file that includes another Explore file and then extends the Explore:

include: "base.explore.lkml" explore: aircraft_information { extends: [aircraft] }

Examples

See the sections above for examples of using include in model files, view files, and Explore files.

Common Challenges

Including Everything with * Can Cause Model Conflicts

Some users like to include everything in a single statement, like this:

include: "*"

This often works fine when only one model has been created within a project. However, when multiple models are in use, the * pattern can cause several types of problems. Because * matches every single file (including model files) model definitions get mixed together.

Most of the time this is not desired and causes a host of problems, such as extra or missing Explores, data access problems, and so on. It’s almost always better to explicitly include only the dashboard and view files as follows:

include: "*.dashboard" include: "*.view"

Including a File with a connection Parameter Can Cause Errors

Including a file that contains a connection parameter causes the connection defined in the primary model file to be overridden by the included file. Most of the time this is not desired and can cause errors in queries. To avoid this, ensure that included files don’t declare a connection.

Autogenerating Multiple Models Can Duplicate Entities

When autogenerating a new model from a connection, the default model file uses this pattern:

include: "*.dashboard" include: "*.view"

When only one model is autogenerated into a project the syntax above works fine. However, if more than one model is autogenerated into a project, there can be some duplication. For example, if all dashboards are included in all models, those dashboards may appear to users more than once (once for each model). To avoid this, you can use more specific references in your models so that everything only appears once:

include: "overview.dashboard" include: "inventory.dashboard"

Including a LookML Dashboard That Can’t Be Found Causes a Warning

The LookML Validator issues a warning if a file has an include parameter that includes a LookML dashboard that the IDE cannot locate. This is often caused by the presence of include: *.dashboard when there are no LookML dashboards present.

Including All View Files Can Affect Performance of LookML Validation

If your project has a large number of view files and you include them all in your model file (include: "*.view"), this may affect the performance of the LookML Validator. Since the LookML Validator checks all of the view files included in the model, you should include only the needed view files in the model file’s include parameter. Consider using strategic naming conventions for view files to enable easy inclusion of groups of views within a model (see example here). Or, if your project is enabled for IDE folders, you can organize your views into folders and use the * wildcard to include all views in a single folder, instead of including all views in your project. See this documentation page for information on using include with IDE folders.

Including All View Files Can Clutter Your Database Schema

For projects that use persistent derived tables (PDTs), you can include the PDT’s view file in your model file. However, each model file that includes the PDT’s view file will create a copy of the PDT in the scratch schema on your database. If you have multiple model files and you include all view files in your model files (include: "*.view"), you may add unnecessary clutter to your database scratch schema. For this reason, be sure that you include a PDT’s view file only in the model files where the PDT is needed.

Things to Know

Clever View File Naming Patterns Can Be Helpful

If your project has IDE folders enabled, you can organize your views into folders and use the * wildcard to include all views in a single folder, instead of including all views in your project. See this documentation page for information on using include with IDE folders.

In cases where many view files need to be managed, you can list each individual view in an include parameter. However, if you name files with a clever prefix or suffix, you may be able to reduce the number of include parameters that you need to write.

For example, instead of naming files like this:

apple.view banana.view cherry.view

You might consider names like this:

apple.fruit.view banana.fruit.view cherry.fruit.view

Then you could reference all of these files with:

include: "*.fruit.view"

When you use a measure of type: count in an Explore, the visualization labels the resulting values with the view name rather than the word “Count.” To avoid confusion, we recommend pluralizing your view name, selecting Show Full Field Name under Series in the visualization settings, or using a view_label with a pluralized version of your view name.

Top