Unlock the power of your data in the cloud! Get hands-on with Google Cloud's core data services like BigQuery and Looker to validate your practical skills in data ingestion, analysis, and management, and earn your Associate Data Practitioner certification!
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.
Last updated
A data team is updating an existing LookML view file (orders.view) to support new reporting requirements. The view already defines a base dimension for customer IDs:
dimension: user_id {
type: number
sql: ${TABLE}.user_id ;;
}
The business requires a new aggregate field that calculates the distinct count of customers who placed orders within the last 30 days. Following LookML modeling best practices for maintainability, how should this field be declared in the view file?
Declare a measure with type: sum, set sql: ${TABLE}.user_id ;;, and omit filters so all rows are calculated.
Declare a dimension_group with type: time and define timeframes: [distinct_count] pointing directly to ${TABLE}.user_id ;;.
Declare a dimension with type: number, write sql: COUNT(DISTINCT ${TABLE}.user_id) ;;, and specify the timeframe inside the SQL definition.
Declare a measure with type: count_distinct, reference the existing dimension using sql: ${user_id} ;;, and apply the date condition using the filters parameter.
Declare a measure with type: sum, set sql: ${TABLE}.user_id ;;, and omit filters so all rows are calculated.
Declare a dimension_group with type: time and define timeframes: [distinct_count] pointing directly to ${TABLE}.user_id ;;.
Declare a dimension with type: number, write sql: COUNT(DISTINCT ${TABLE}.user_id) ;;, and specify the timeframe inside the SQL definition.
Declare a measure with type: count_distinct, reference the existing dimension using sql: ${user_id} ;;, and apply the date condition using the filters parameter.
In LookML, a measure is a field that computes an aggregate calculation across multiple rows of data, such as counts, sums, averages, or distinct counts. A dimension represents a row-level attribute or fact. When building data models, LookML uses the substitution operator (${...}) to reference database columns or other LookML fields in a modular, maintainable hierarchy.
type: count_distinct directs Looker to generate the appropriate SQL aggregation (such as COUNT(DISTINCT ...)) across rows.filters parameter applies a conditional filter directly to the calculation (e.g., filters: [created_date: "30 days"]), ensuring only qualifying rows are aggregated.${user_id} instead of ${TABLE}.user_id ensures that if the underlying database column name ever changes in the future, developers only need to update the base dimension's sql parameter in one location.${field_name} creates a single reference point for the physical column in the data model.type: count_distinct into dialect-specific SQL functions without manual SQL string manipulation.Declaring an aggregate metric as a measure and referencing the base dimension with ${field_name} follows core LookML modeling standards. It separates row-level dimensions from aggregated metrics while keeping the code maintainable and DRY (Don't Repeat Yourself).