Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Business Intelligence with Looker Cookbook

You're reading from   Business Intelligence with Looker Cookbook Create BI solutions and data applications to explore and share insights in real time

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781800560956
Length 256 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Khrystyna Grynko Khrystyna Grynko
Author Profile Icon Khrystyna Grynko
Khrystyna Grynko
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Chapter 1: Getting Started with Looker FREE CHAPTER 2. Chapter 2: Configuring Views and Models in a LookML Project 3. Chapter 3: Working with Data in Explores 4. Chapter 4: Customizing and Serving Dashboards 5. Chapter 5: Making Dashboards Interactive through Dynamic Elements 6. Chapter 6: Troubleshooting Looker 7. Chapter 7: Integrating Looker with Other Applications 8. Chapter 8: Organizing the Looker Environment 9. Chapter 9: Administering and Monitoring Looker 10. Chapter 10: Preparing to Develop Looker Applications 11. Index 12. Other Books You May Enjoy

Making and saving changes in views

Views in Looker are tables of data that are defined in LookML. Views can be based on existing database tables, or they can be derived from tables that are created using LookML-based query or SQL query.

Views are used to organize data in Looker. They can also be used to create custom dimensions and measures. Views are typically declared in view files, with one view per file. Each view file contains a definition of the table, including the fields that are included in the view.

Views can be used in Explores to create data visualizations. They can also be used in joins to combine data from multiple views.

Getting ready

Make sure you are in Development Mode. Go to your LookML project environment and, on the left, open the views section/list. At this stage, you should see only one view based on the table we have in our BigQuery dataset – device_category_jan2021. Select this view to see the view’s LookML code in the code editor in the middle of the page (Figure 1.26).

Figure 1.26 – The device_category view

Figure 1.26 – The device_category view

We will make small changes in the views to see how the LookML code works and how you can prepare your data in this Looker semantic layer for your users.

How to do it...

The steps for this recipe are as follows:

  1. Place the cursor after line 6 (sql: ${TABLE}.Device_category ;;) and press Enter on your keyboard. In Looker, there’s a special character – $ – that acts as a substitution operator. It’s used to create more reusable and modular LookML code, allowing you to reference elements that have already been defined within your code. This helps to make your code cleaner, more organized, and easier to maintain.
  2. Explore the Quick Help section on the right that proposes different elements that you can add to enrich, enhance, or complete your dimension (Figure 1.27).
Figure 1.27 – Quick Help

Figure 1.27 – Quick Help

  1. In the empty line, start typing the word description, then add a description similar or different to the one in Figure 1.28.
Figure 1.28 – Dimension description

Figure 1.28 – Dimension description

  1. Place the cursor after line 21 (type: count) and press Enter on your keyboard.
  2. In the empty line, start typing the word description, then add a description similar or different to the one in Figure 1.29.
Figure 1.29 – Measure description

Figure 1.29 – Measure description

  1. Place your cursor on line 23 after the curly bracket and press Enter. You can now start creating new measures. Copy and paste this code to create a new measure that will count the total of sessions (per device, per day, depending on the dimensions that you will choose for your visualization later):
      measure: total_sessions {
        type: sum
        sql: ${nb_of_sessions} ;;
      }
  2. Now that we have added some descriptions and created a new measure, we want to make sure that our code is correct. To do this, you should click on Save Changes, then click on Validate LookML in the top-right corner (Figure 1.30). If everything is correct, you will see No LookML errors found in the Project Health window on the right.
Figure 1.30 – Validate LookML

Figure 1.30 – Validate LookML

  1. Click on Save Changes.
  2. You will now see the Commit Changes and Push button in the top-right corner; you might want to use it when you are ready to share your work with your teammates (if you don’t push changes to your Git repository, your team won’t be able to see your LookML project and the changes made to it). Don’t rush to commit. Verify your LookML edits by testing them in an Explore before committing permanently (Explores will be explained in the next recipe).

How it works...

As explained previously, a view is a representation of a table in LookML that contains dimensions and measures that are used to define the data that can be used in Explores to create data visualizations.

In Looker, dimensions are filterable data columns (like dates, names, IDs) that often come from your tables, but some can be built within LookML. For example, device_category and session_date are different dimensions within our BigQuery dataset.

Measures are aggregations of one or more dimensions (or unique attributes of the data) such as a count or average. Measures allow you to calculate key performance indicators (KPIs) that help your users analyze data using different aggregated attributes.

Once the view or the views are created, and all the necessary dimensions and metrics are enriched/completed/added, you can save changes and use your views in models and Explores.

See also

You have been reading a chapter from
Business Intelligence with Looker Cookbook
Published in: May 2024
Publisher: Packt
ISBN-13: 9781800560956
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image