Measures are aggregated computations performed on specific columns within your model. They are used to derive insightful metrics, often serving as the foundation for more complex analytical structures. Measures can range from simple sums or averages to intricate calculations utilizing various dimensions, conditions, and data transformations.
Measures are defined using the following structure:
Copy
measures: - name: [Measure Name] description: [Description] agg: [Aggregation Type] expr: [SQL Expression or Column Name] agg_params: [Aggregation Specific Properties] agg_time_dimension: [Time Dimension] non_additive_dimension: [Dimensions that shouldn't be aggregated] label: [Label for the measure]
For example, in a semantic model for transactions:
Copy
semantic_models: - name: transactions description: A record of all transactions. Multiple transactions are recorded per SKU for carts. model: {{ ref("fact_transactions") }} measures: - name: transaction_amount_usd description: Total USD value of transactions expr: transaction_amount_usd agg: sum label: Transaction Amount (USD) - name: average_transaction description: Average USD value of transactions per day expr: transaction_amount_usd agg: average label: Average Daily Transaction
Findly supports a rich set of aggregation types to cater to diverse data analysis needs:
Basic aggregations provide elementary mathematical operations on data.
sum: Total of values.
min: Smallest value.
max: Largest value.
average: Mean of values.
When creating measures, ensure that the data types and SQL functions are
compatible with your specific data platform’s capabilities, as these can vary.
Measures are pivotal for deriving insights from your data through metrics. By understanding and effectively utilizing measures, you can generate more valuable and accurate metrics for your analyses.
FAQ: Are measures dependent on dimensions?
While measures often utilize dimensions for their calculations, they are not
strictly dependent on them. However, when applying filters or other conditions
based on dimensions, it’s essential to ensure the correct relationships and
joins are maintained for accurate results.