This page refers to the
queryparameter that is part of an Explore.
querycan also be used as part of an aggregate table, as described on theaggregate_tableparameter documentation page.
explore: explore_name {
query: query_name {
dimensions: [dimension1, dimension2, ... ]
measures: [measure1, measure2, ... ]
label: "Display Name in Field Picker"
description: "Information about this query"
pivots: [dimension1, dimension2, ... ]
sorts: [field1: asc, field2: desc, ... ]
filters: [field1: "value1", field2: "value2", ... ]
limit: 100
}
...
}
|
Hierarchy
query |
Default Value
None
Accepts
The name of the query and subparameters to define the query
|
You can use the query parameter to create modeled analyses for an Explore. The modeled analyses are listed in the Quick Start section of a blank Explore, or in the Quick Start pop-up after an Explore has already been run. See the Example section on this page for how it works.
Modeled analyses are helpful to beginner Looker users, since you can specify elements like the dimensions, measures, filters, and pivots that may be the most relevant and insightful.
Instead of creating the query's LookML from scratch, you can use an Explore to create the query's base LookML for you. For details, see the next section, Getting query LookML from an Explore.
The query parameter has the following subparameters:
labelquery. The label is what is displayed in the Explore's field picker for the query. label: "Weekly Sales Totals"descriptiondescription: "Total value of all sales per day"
dimensionsdimensions field uses this syntax: dimensions: [dimension1, dimension2, ...]
dimensions: [orders.created_month, orders.country]measuresmeasures field uses this syntax: measures: [measure1, measure2, ...]
measures: [orders.count]filtersquery. Filters are added to the WHERE clause of the SQL that generates the query.
The filters field uses this syntax: filters: [field_name_1: "value1", field_name_2: "value2", ...]
filters: [orders.country: "United States", orders.state: "California"]
limitlimit: 10
sortsquery.
The sorts field uses this syntax: sorts: [field1: asc|desc, field2: asc|desc, ...]
sorts: [order_items.total_sales: asc]pivotspivots field uses this syntax: pivots: [dimension1, dimension2, ...]NOTE: The fields specified in the pivots parameter must also be specified in the dimensions parameter of the query.
pivots: [created_quarter]timezonetimezone parameter is not supported for the query parameter that is a subparameter of explore. A query under explore uses the same time zone used by the explore.
As a shortcut, Looker developers can borrow the functionality used to generate aggregate_table LookML from an Explore, then copy the aggregate table query LookML and use it as a starting point for modeled analysis LookML.
When you copy the LookML for an aggregate table, you'll also copy some parameters that you don't want for your modeled query LookML. Specifically, once you copy the aggregate table LookML you need to delete the
aggregate_tableandmaterializationparameters, since they apply only to aggregate tables. (See theaggregate_tableparameter documentation page for more information about those parameters.)Also, the aggregate table
queryparameter supports only a subset of the parameters that are supported by modeled Explore queries. This means that once you copy the aggregate tablequeryLookML, you can use additional parameters for your modeled query. See the Defining a query in LookML section on this page for a full list of the parameters supported for modeled queries.
To use an Explore to get a base for your modeled query LookML:
Select Get LookML from the Explore Actions gear menu. This option is available for Looker developers only.
Select the Aggregate Table tab.
Looker provides the LookML for an Explore refinement for an aggregate table. We can use the aggregate table's query LookML and modify that for a modeled Explore query. Copy the LookML and paste it into the associated model file, which is indicated in the comment preceding the Explore refinement. If the Explore is defined in a separate Explore file, and not in a model file, you can add the refinement to the Explore's file instead of the model file.
From here, you can modify the aggregate table LookML to use for a modeled query:
Keep only the query parameter and its subparameters. Delete the aggregate_table and materialization parameters, since they apply only to aggregate tables.
Add a name for the query. As shown in the Example section on this page, the syntax is:
query: query_nameOptionally, fill in any additional parameters for your modeled query. See the Defining a query in LookML section on this page for a full list of parameters supported for modeled queries.
This example creates an order_count_by_month modeled query for the order_items Explore:
explore: +order_items {
query: order_count_by_month {
description: "Number of orders placed by month in 2019"
dimensions: [orders.created_month]
measures: [orders.count]
filters: [orders.created_date: "2019"]
}
}
Users can run the Quick Start analysis from the Quick Start section of the Order Items Explore.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-22 UTC.