Skip to main content
For an easier building experience, build your query view using the workbook and then promote it to the shared model.

Syntax

query:
  fields:
    <view_name>.<field_name>
    <view_name>.<field_name>: <optional_alias>
  base_view: <view_name>
  filters: [ ... ]

Properties

fields
array
Fields to include in the query view, specified as view_name.field_name. To alias fields, specify as view_name.field_name: alias.
base_view
string
The view to use as the base for the query.
filters
object
Filters to apply to the query view, specified using filter syntax.

Examples

In this example, query.fields contains aliased fields - that is, the string after the colon defines the alias. For example, created_at. The dimensions.sales field is an example of a field that was not aliased.
Example with aliased fields
query:
  fields:
    order_items.created_at[date]: created_at
    order_items.user_id: user_id
    order_items.total_sales
  filters:
    orders.amount_returns:
      not: 0
  base_view: order_items

dimensions:
  created_at:
    timeframes: [date]
    sql: created_at
  user_id:
    sql: user_id
  sales:
    sql: order_items__total_sales