How to use a dimension from another view in Looker?

  • Datameer, Inc.
  • January 25, 2018
Get Started Transforming Your Data in Snowflake

We can use a substitution operator ($) to reference dimensions and measures from other views in LookML.

Consider the following code where we have two views, example_A and example_B .  

############################################

View: example_A { 

sql_table_name: xyz ;;

dimension: field_A {
type: number
sql: ${TABLE}.id ;;
}
######################################
View: example_B {

 sql_table_name: abc ;;

dimension: field_B {
type: number
sql: ${TABLE}.id ;;
}

dimension: field_from_example_A {
type: number
sql: ${example_A.field_A} ;;

}

############################################

 

As you can see, the view example_B has a field called field_from_example_A, which is referencing field_A from example_A by using the substitution operator ($) as ${example_A.field_A} . 

Please note : Both the views should be joined in a common Explore to reference fields from each other.

 


Up Next:

Read How to allow dimension/measure tooltip in Looker to show the description to user when pointing over name of the object in a Look (table)?