Dimensions offer a way to group or filter data based on categories or timeframes. Think of them as special labels that simplify data organization and analysis. Within data platforms, dimensions are integral components of a semantic model, alongside identifiers and measures.In SQL, dimensions typically align with the group by clause of your SQL query.
Dimensions are logically defined using the following parameters:
Copy
dimensions: - name: [name] type: [Categorical or Time] type_params: [specific type parameters] description: [description] expr: [column_name_or_sql_expression] # Defaults to dimension name if omitted
For example, in a semantic model for transactions:
Copy
semantic_models: - name: transactions description: A record of every transaction. Carts are grouped as multiple transactions per SKU. model: {{ ref("fact_transactions") }} defaults: agg_time_dimension: metric_time dimensions: - name: metric_time type: time expr: date_trunc('day', ts) - name: is_bulk_transaction type: categorical expr: case when quantity > 10 then true else false end
Note: To correctly identify and process dimensions, each dimension must be associated with a primary identifier.
Findly supports two primary types of dimensions: Categorical and Time.
Categorical dimensions facilitate grouping metrics by categories, like product type or geographical region. They can reference existing columns or be derived from SQL expressions.Example:
Copy
dimensions: - name: is_bulk_transaction type: categorical expr: case when quantity > 10 then true else false end
Dimensions play a pivotal role in organizing, filtering, and analyzing your data. By mastering the use of dimensions, you can create more meaningful and insightful data models.
FAQ: Are there any constraints on naming dimensions?
Yes, dimension names must be unique within a single semantic model. They can
be reused across different models, as Findly uses joins to correctly
distinguish them.