Required Dimension in Explore

Iโ€™m building an explore that will be used for a very specific purpose, and because of this there are certain dimensions that should always be selected when creating looks. Is there a way to automatically select these dimensions when the user begins creating a Look using this Explore, or require that these dimensions be selected? I know I can add some logic to a derived table query to account for this, but I was hoping there was a better approach that could be used with LookML.

2 6 2,107
6 REPLIES 6

Hey Daron! Welcome ๐Ÿ™‚

This isnโ€™t possible yet in any standard way, but hereโ€™s three non-standard ideas:

Thereโ€™s the required_fields parameter that lets you choose fields to be added to a query when a certain field is picked-- But it doesnโ€™t let you pre-seed dimensions in an explore. Sharing in case it fits your needs, but it sounds like it wonโ€™t.

I have, in the past, done some super hacky sql_always_where liquid logic to prevent any query from running successfully unless certain fields are selected, but thatโ€™s not a great end user experience.
Basically:

sql_always_where: 
{% if view_name.field_name._is_selected %}
1=1
{% else %}
"You forgot to add view_name.field_name to the Explore"

which will throw a sql syntax error at query runtime. ๐Ÿคข, but depending on how badly you need this, maybe a viable choice.

One idea thatโ€™s also not perfect would be to create the explore youโ€™d like users to start with, and then just socialize that URL as the โ€œbaseโ€ URL for building on that explore. If you have a custom homepage, you could leverage that to route users to the pre-seeded URL.

Do any of those fit your case?

Thanks so much for the suggestions. I have some liquid logic similar to what you suggested in the query already ๐Ÿ˜…. I do like the idea of sharing the base URL that includes the default columns. It would be neat if an explore could have a default URL for scenarios like this.

Something like default_fields_for_explore would be nice.  While we can use required_fields to force the query, it would be nice if anyone starting a new explore didnโ€™t have to start from scratch.  Of course we can have them start with a Look, but the tool makes it easy for users to start a new Explore.

I am so much in need of this right now. Would be a very useful feature where selecting a specific dimension is necessary for the explore to work

I know this is an older thread, but have you considered configuring Quick Starts for your explore? They are new since the OP, but @Dawid perhaps they would be helpful. You use the query parameter in the Explore LookML: https://cloud.google.com/looker/docs/reference/param-explore-query. We've found them very helpful at seeding starting queries for users. 

I used Quick Starts but for a different reason, to help people start exploring, it doesn't solve the problem of needing a required dimension. Thankfully, I didn't need it since last time ๐Ÿ™‚

Top Labels in this Space
Top Solution Authors