How to structure your LookML IDE and code

chynna calip
SlateCo
Published in
3 min readMay 7, 2021

Are you having trouble structuring your LookML? Have you found yourself trying to hunt down a dimension or measure with increasing confusion? In many cases LookML becomes its own organized mess understood only by the people working on it, but as you scale with more Looker developers a best practice should be implemented!

I have had the most practice and experience in this and have been able to fine tune what I think the best way in writing LookML code and structuring/styling your code. I hope you find this blog as the one that sticks to you for LookML developing.

Even if it is a quick or one off creation of a view table, I strongly recommend you keep to this structure no matter what! As the saying goes“measure twice cut once.” We feel that applies equally to LookML code.

There are some really great open source lint tools for LookML that you can use. I recommend having some git control so there is always someone to review code and the standard process is enforced, because it can and will get out of hand.

So let’s begin. How to structure a view file:

Below is a snippet of what this structure looks like

  1. Update Log
  • Most of the time we use an update log to know when the view file was created or uploaded. You can look this up in your git repository but this will save you 3+ clicks.
  • Another thing to add in this section is if it is a SQL-based derived table and the SQL logic has been updated.

2. Description

  • It is always helpful to just add some context about what the table will show, what it is for, or how it was set up.

3. Dimensions

  • This section is for dimensions generated by sql.

4. Custom Dimensions

This section is for all the custom dimensions, such as dimensions with case when statements, filters, parameters, etc.

5. Measures

  • This section is for measures.
  • We recommend grouping measures that are related to each other.

6. Sets

  • This section is for field sets.
  • We recommend structuring these alphabetically.

Below is our standard groupings:

  • Using curly brackets {} helps visually organize your code in collapsable blocks.
  • Do not be afraid to use more brackets to group measures or dimensions by categories or alignment.
######################################################################### Update Log:##### 01/01/2021 — CC created derived table######################################################################################################################################### Description:# Purpose of this table to####################################################################view: derived_engage_feature_shop_setting {
derived_table: {
sql:
;;
}
############################################################################## START OF DIMENSIONS {#########################################################################[DIMENSION HERE, REMEMBER ONLY COLUMNS GENERATED BY SQL TABLE][DIMENSION HERE, REMEMBER ONLY COLUMNS GENERATED BY SQL TABLE][DIMENSION HERE, REMEMBER ONLY COLUMNS GENERATED BY SQL TABLE]############################################################################## END OF DIMENSIONS }#########################################################################
############################################################################## START OF CUSTOM DIMENSIONS {#########################################################################[CUSTOM DIMENSIONS HERE]############################################################################## END OF CUSTOM DIMENSIONS }#########################################################################
############################################################################## START OF MEASURES {#########################################################################[MEASURES HERE]############################################################################## END OF MEASURES }#########################################################################
############################################################################## START OF SETS {#########################################################################[SETS HERE]############################################################################## END OF SETS }#########################################################################}

Within every dimension and measure, we adhere to this pattern:

  1. Dimension name matches the sql (if present)
  2. Always provide a description of dimension or measure, etc.

Work With Us

SLATE is an engineering company with a focus on modern approaches to data architecture and software development, and delivers custom solutions that allow organizations to gain insights to drive effective decision making. If you have a problem that you’d like us to help you with, then you can contact us via our website!

--

--

chynna calip
SlateCo
Editor for

Hi my name is Chynna as in ‘CHEEEEEEEEE-NAH’ and I’m no pro, but I do like data…and desserts.