Required Dimension in Explore

  • 23 March 2020
  • 4 replies

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.

4 replies

Userlevel 7
Badge +1

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.


{% if view_name.field_name._is_selected %}
{% 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.

Userlevel 7
Badge +1

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