Skip to main content

AML Dataset Fields

Knowledge Checkpoint

A grasp of these concepts will help you understand this documentation better:

Introduction

To enable cross-model calculations and have a logical structure for the analytics codebase, we can also create Dimensions and Metrics within a Dataset:

  • Dataset Dimension is analogous to Model Dimension
  • Dataset Metric is analogous to Model Measure. However, Dataset Metric has more functionalities than Model Measure.

However, their definition and usage are different from those of the Model's counterparts.

Dimension

In Dataset Dimension, you can combine dimensions from one or more models. In general, Dataset Dimension's declaration is similar to that of Model Dimension, except for an extra model parameter that specifies the source model of the cross-model reference.

Parameter Definition

Parameter nameRequiredDescription
modelYesThe source model of the cross-model reference. The dimension also appears under this model in the exploration UI.
labelYesHow the dimension appears in the exploration UI.
typeYesData type of the dimension. Possible values: 'text', 'number', 'date', 'datetime', 'truefalse', 'json', 'unknown'.
definitionNoHow the dimension is calculated, using @sql or @aql syntax.
descriptionNoDescribes the semantic of the dimension.
hiddenNoDefault false. Hides the dimension from the Exploration interface of Dataset and Report. This is not a Security Feature (reason).
formatNoDisplay format for the dimension's value. See Number Format and Date Format.

Example of Dataset Dimension Definition

Dataset e_commerce {
(...)

dimension full_name {
model: users
type: 'text'
label: 'Full name'
definition: @aql concat(users.first_name, ' ', users.last_name);;
}

dimension age_by_year {
model: users
type: 'text'
label: 'Full name'
definition: @aql date_diff('day', users.birth_date, @now) / 365;;
}
}

Metric

Datasets can also expose Metrics: aggregations defined in AQL that can span multiple models.

Metrics defined inline inside a Dataset { ... } block use the same Metric type as standalone, reusable metric definitions. For the full parameter list, examples, and how to organize them, see AML Metric.

Notes

Dataset Dimension vs. Model Dimension

Even though it is possible to define dimensions in both Dataset and Model, we recommend the following:

  • If the dimension transforms fields within the same model, it should be a Model Dimension.
  • If the dimension transforms fields across multiple models, it should be a Dataset Dimension.

Dataset Metric vs. Model Measure

Similarly, even though it is possible to define a certain aggregation in both the Dataset and Model levels, we recommend the following:

  • If the aggregation transforms fields within the same model, it should be a Model Measure.
  • If the aggregation transforms fields across multiple models, it should be a Dataset Metric

As mentioned earlier, although Dataset Metric is analogous to Model Measure, it is actually much more powerful. For a more extensive discussion of metrics, see What is a metric? and Create metrics in datasets.


Open Markdown
Let us know what you think about this document :)