Define Your Measures
Measures are the quantitative metrics that power your dashboards and reports. They represent numeric calculations derived from your underlying data through SQL aggregation functions and expressions. These measures transform raw data into meaningful business insights, such as total revenue, average order value, or customer count.
Measures are the "how much" and "how many" of your data. They provide the numerical foundation for your analysis, enabling you to:
- Quantify performance: Track key business metrics like revenue, growth, and efficiency
- Support decision-making: Provide concrete numbers for business decisions
Supported SQL Functions
- Standard SQL numeric operators and functions
- Common SQL aggregates:
AVG
,COUNT
,MAX
,MIN
,SUM
,STDDEV
,VARIANCE
- Advanced aggregates (engine-dependent):
APPROX_COUNT_DISTINCT
,APPROX_QUANTILE
,STDDEV_POP
,STDDEV_SAMP
,VAR_POP
,VAR_SAMP
- Filtered aggregates can be used to filter the set of rows fed to the aggregate functions (syntax may vary by engine)
Different OLAP engines support varying SQL dialects and functions. While standard SQL functions work across engines, some advanced features may be engine-specific. For engine-specific documentation, see:
- DuckDB: DuckDB SQL documentation
- ClickHouse: ClickHouse SQL documentation
- Druid: Druid SQL documentation
- Pinot: Pinot SQL documentation
As an example, if you have a table of sales events with the sales price and customer ID, you could calculate the following measures with these aggregates and expressions:
- Number of sales:
COUNT(*)
- Total revenue:
SUM(sales_price)
- Revenue per customer:
CAST(SUM(sales_price) AS FLOAT)/CAST(COUNT(DISTINCT customer_id) AS FLOAT)
- Number of orders with order value more than $100:
COUNT(*) FILTER (WHERE order_val > 100)
(syntax may vary by engine)
Explore these advanced capabilities to enhance your measures:
- Measure Formatting - Learn how to format and display your measures effectively
- Case Statements and Filters - Use conditional logic and filtering in your measures
- Referencing Measures - Reference and combine existing measures in your calculations
- Quantiles - Calculate percentiles and quantiles for statistical analysis
- Fixed Measures - Create measures with fixed values and constants
- Window Functions - Apply window functions for advanced analytical operations