Question

Best practice for exposing specific fields from inherited view

  • 3 August 2017
  • 4 replies
  • 228 views

We would like to make use of the extend / inheritance features of Looker as much as we could. I need to figure out if there is a best practice to show only particular fields from the inherited view. Let me explain with an example (which is actually a real life use case I’m working on now)


Imagine an order view file like the following with 10s of dimensions defined:


- view: order {
dimension: customer_id
dimension: merchant_id
dimension: order_id
dimension: latest_order
...
}

(I’m excluding the definitions as they are not relevant to the discussion)


Then we have another view that extends this and overwrite the definition of customer_id and order_id:


- view: new_order {
extends: [order]
dimension: customer_id
dimension: order_id
}

So my goal is to display only customer_id, order_id and latest_date in the final look that is based on new_order. We don’t need to (or want to) display the 10s of dimensions inherited from ‘order’ view (just to keep the All Fields view on explore to the minimum set of required fields for this particular report)


Finally, the model file that I couldn’t validate:


include: "*.view"
- explore: new_order {
fields: [new_order.customer_id, new_order.order_id, `'new_order.latest_order'`]
}

Looker complains of missing reference for latest_order. I try using the original view namespace, table name, $ substitution to refer to latest_order but the error stays.


Of course, I could just declare latest_order field in new_order view with the same definition in order view. But I believe that defeats the purpose of inheritance, no?


Your suggestions are appreciated. I’m still learning Looker so perhaps I’m overlooking a scope definition somewhere.


4 replies

Userlevel 3

Hey @frat. I’m not sure if you were just trying to call attention to “lastest_order” with the backtick and apostrophe, or if that’s literally what is written in your LookML. If that is in your LookML, that may be a problem. Also, I think any field referenced in fields needs to be fully scoped.


So instead of this:


fields: [customer_id, order_id, `'latest_order'`]

I think you would want this:


fields: [new_order.customer_id, new_order.order_id, new_order.latest_order]

@Brett_Sauve Thanks for the quick response.


Please ignore the backtick, indeed I put it there to emphasize the issue I’m having.


Actually, just before you replied I edited my response to show that your suggestion doesn’t work neither. (I tried all the combinations of references)


So I get from your response that what I’m asking is not possible currently. It’d be a nice little feature update in my humble opinion.

Userlevel 3

@frat it probably is possible, I’m just not 100% certain what I’m missing. Perhaps an Analyst will be able to tell us.

@Brett_Sauve

Ah I solved the mystery. I was refering to a date dimension group and picking ‘_raw’ field. When I select ‘_date’ field, Looker stops complaining and shows me that particular field.

Reply