looker

How do I join a measure field from a different view in Google Looker?


Google Looker dev question: How do I join a measure like sum_order_value from another view B to an existing view A?

I added it as a measure at the bottom of the view file:

  measure: sum_order_value {
    type: number
    description: "sum_order_value"
    sql:  ${view_A} ;;
  }

Error message received in Looker: "Unknown or inaccessible field"

Where in my view file do I perform the join with the table?


Solution

  • For example, assume that you want to add a measure from View_B to View_A. So in View_A, you can refer to a measure from another view by including ${viewname.fieldname} in the sql part. Just make sure that both views exist in the explore.

      measure: sum_order_value {
        type: number
        description: "sum_order_value"
        sql:  ${view_A.sum_order_value} ;;
      }