Skip to main content

Dataset's Custom Views

Note

This feature is available from Standard plan and above.

Introduction

Dataset views allow admins/analysts to customize how datasets are presented to end users without changing the underlying models, fields, or metrics.

This makes datasets more user-friendly because end users now only see relevant, curated fields.

datasetviewdoc.gif

How it works

By default, in the Exploration view, all models, fields and metrics you defined will be displayed. Furthermore:

  • Models are displayed by the order listed in dataset files.
  • Fields are grouped by dimensions and measures, then displayed by the order listed in the model files.
  • Metrics are displayed in a special group on top of the models
Before

By creating a dataset view, analysts can:

  • Reorder fields and models to highlight frequently used models and fields, or indicating a hierarchy.
  • Display only relevant models and fields to simplify large datasets with multiple models and fields.
  • Group relevant models, fields and metrics to aid navigation.
After

When a dataset has a custom view, the view is displayed by default. This makes it easy for end users to get used to the dataset. You can switch to the original view if you prefer to.

Syntax

Dataset view is declared with the view keyword. Properties to be included are declared with the form property_type property_name:

Dataset dataset_name {
...

view {

// Display a subset of models (model_1, model_2)
model model_1 {
// Display a subset of fields
field dimension_1
field measure_1

// Declare a group of fields
group field_group_name {
field dimension_2
field measure_2
}
}

model model_2 { } // Leave the inside blank to display all fields in this model

// Declare a group of models
group model_group_name {
model model_4 { }
model model_5 { }
}

// Declare a group of metrics
group metric_group_name {
metric metric_1
metric metric_1
}
}
}

Example view of ecommerce dataset:

Dataset ecommerce {
...

models: [users, products, orders, dim_dates]
relationships: [
relationship(orders.user_id > users.id, true),
relationship(orders.product_id > products.id, true),
relationship(orders.order_date > dim_dates.id, true)
]
view {
model products { } // Display all fields from Products

model users {
// Display selected fields from Users
field id
field email
field age

// Create group "Customer Name" containing fields within model Users
group customer_name {
field first_name
field last_name
field full _name
}
}

// Create group "Order Master" containing two models Orders and Dates
group order_master {
model orders {
field order_value
field id
field order_status
field order_discount
}

model dim_dates {
field year
field month name
field day
field week_number
field quarter
}
}
}
}
view-syntax-structure.png

Hierarchy of a properties

The following properties are accepted in the view definition:

  • model: to specify models to be included in the view.
    • field: to specify model fields to be included. field covers both dimensions and measures.
    • group: within a model, this is used to create a group of fields.
  • group: to create a group containing other objects, like model and metric.

The hierarchy of the properties can be visualized as follows:

Dataset
└── view
├── model
│ ├── field
│ └── group
│ └── field
├── group
│ └── model
│ ├── field
│ └── group
│ └── field
└── group
└── metric

Notes:

  • metric must be declared in a group.
  • Currently we don't support declaring fields without a container model. That means you cannot do this:
    Dataset
    └── view
    └── group
    └── model.field
  • "Group of groups" is not allowed. In other words, the following structure is invalid:
    Dataset
    └── view
    └── group
    └── group

Let us know what you think about this document :)