Skip to main content

Dataset's Custom Views

Note

This feature is available from Standard plan and above.

Introduction

When designing a dataset, it can be challenging to strike the right balance between comprehensiveness and usability. A "comprehensive" dataset with a lot of models and fields offers high amount of information, but it can be overwhelming to the end users. On the other hand, a model focusing too much on being "easy to use" may not have enough information and is not as useful for power users.

To address this challenge, we introduce Dataset Custom View which allows data analysts to further customize how their datasets look to the end users, while the underlying models, fields and metrics are unaffected.

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.

How to create dataset view

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 follow:

Dataset
└── view
├── model
│ ├── field
│ └── group
│ └── field
├── group
│ └── model
│ ├── field
│ └── group
│ └── field
└── group
└── metric
caution
  • metric must be declared in a group.
  • "Group of groups" is not allowed. In other words, the following structure is invalid:
    Dataset
    └── view
    └── group
    └── group

Syntax

Suppose we have the following models and datasets setup as follow:

Setup
// Model definitions in .model.aml files
Model model_1 {
...
dimension dimension_1 {...}
dimension dimension_2 {...}
dimension dimension_3 {...}

measure measure_1 {...}
measure measure_2 {...}
measure measure_3 {...}
}

Model model_2 {...}
Model model_3 {...}
Model model_4 {...}
Model model_5 {...}

// Dataset definition in .dataset.aml file
Dataset dataset_name {
...
models: [
model_1,
model_2,
model_3
]

relationships: [...]

metric metric_1 {...}
metric metric_2 {...}
metric metric_3 {...}

// view is defined as a property in dataset
view {
...
}
}

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

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

Let us know what you think about this document :)