arrow_back

How to Build a BI Dashboard Using Google Data Studio and BigQuery

Join Sign in

How to Build a BI Dashboard Using Google Data Studio and BigQuery

1 hour 5 Credits

GSP403

Google Cloud self-paced labs logo

Overview

For as long as business intelligence (BI) has been around, visualization tools have played an important role in helping analysts and decision-makers quickly get insights from data.

In this lab, you'll learn how to build a BI dashboard with Data Studio as the front end, powered by BigQuery on the back end. It assumes some familiarity with those products. For more information, review the background docs ( BigQuery concepts, Data Studio overview).

Setup

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Usecase

For this lab, you'll be a manager of tree services for a large city. You make important decisions based on usage logs data, stored in large (multiple TBs) date-partitioned tables in a BigQuery dataset called "Trees".

To get business value out of that data as quickly as possible, build a dashboard for analysts that provides visualizations of trends and patterns in your data.

Solution overview

Typically, a dashboard shows an aggregated view of usage — it doesn't need details all the way to the level of an order ID, for instance. So, to reduce query costs, you'll first aggregate your needed logs into another dataset called "Reports" then create a table of aggregated data. You'll query the table from the Data Studio dashboard. This way, when your dashboard is refreshed, the reporting dataset queries process less data. Since usage logs from the past never change, you'll only refresh new usage data into the Reports dataset.

The data flow from a dataset containing granular data to a dataset containing an aggregate table, then to the Data Studio dashboard

Task 1. Uploading queryable data

In this section, you pull in some public data so you can practice running SQL commands in BigQuery.

Open the BigQuery console

  1. In the Google Cloud Console, select Navigation menu > BigQuery.

The Welcome to BigQuery in the Cloud Console message box opens. This message box provides a link to the quickstart guide and the release notes.

  1. Click Done.

The BigQuery console opens.

  1. Click on the + ADD DATA link, then select Explore public datasets.

The expanded Add Data menu which includes the option 'Explore public datasets'

  1. Search for "trees" and press Enter.

  2. Click on the Street Trees tile, then click View Dataset.

A new tab opens, a new project called bigquery-public-data is added to the Explorer panel:

The bigquery-public-data project listed in the Explorer panel

Note: If the new project bigquery-public-data doesn't appear to the Explorer panel, then click on + ADD DATA > Pin a project > Enter project name (bigquery-public-data) and Pin.

Task 2. Create a reports dataset in BigQuery

Next you'll create a new dataset called Reports in your project. A separate dataset has a couple of benefits: it reduces the amount of data queried by the dashboard, and it removes unnecessary access to your source datasets by users who are only interested in aggregated data.

  1. Click on the project name that starts with "qwiklabs", then click on View Actions.

  2. Click on Create dataset and call it "Reports".

Click Check my progress to verify the objective. Create a reports dataset in BigQuery

Task 3. Query the dashboard data

Next you run a one-time query to pull the data for the last year, summarizing:

  • The number of trees planted each month

  • Which species of trees were planted

  • Who the caretaker of the trees is

  • Address of the planted trees

  • Tree site information

  1. Add the following to the query editor:

SELECT TIMESTAMP_TRUNC(plant_date, MONTH) as plant_month, COUNT(tree_id) AS total_trees, species, care_taker, address, site_info FROM `bigquery-public-data.san_francisco_trees.street_trees` WHERE address IS NOT NULL AND plant_date >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 365 DAY) AND plant_date < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY) GROUP BY plant_month, species, care_taker, address, site_info
  1. Click the More button, and select Query settings from the dropdown menu.

The More button and its expanded menu, with the Query Settings option highlighted

  • Select Set a destination table for query results.
  • For Dataset name, type Reports.
  • Create a name for the table, like "Trees".
  • For Destination table write preference, select Write if empty.

The Query Settings dialog box displaying the updated settings

Because you specified a Table name and selected the Write if empty preference, the query creates a table if the table does not already exist.

  1. Accept the other default settings and click Save.

  2. Click Run to run the query.

When the query completes, you are on the Results tab, where you can see the data.

The Query results table displaying six rows of data

Click Check my progress to verify the objective. Query to pull the data for last year

Task 4. Scheduling queries in BigQuery

Note: This is a beta release of scheduling queries in BigQuery. This product might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

To keep your dashboard up-to-date, you can schedule queries to run on a recurring basis. Scheduled queries must be written in standard SQL, which can include Data Definition Language (DDL) and Data Manipulation Language (DML) statements. The query string and destination table can be parameterized, allowing you to organize query results by date and time.

Now you add a query that checks each day for new data. When new trees are planted, you'll get the additional stats updated directly into the reports.trees table.

  1. Click Compose New Query and run the following query to pull incremental data into the reports.trees table on a daily basis using the scheduled query feature:

SELECT TIMESTAMP_TRUNC(plant_date, MONTH) as plant_month, COUNT(tree_id) AS total_trees, species, care_taker, address, site_info FROM `bigquery-public-data.san_francisco_trees.street_trees` WHERE address IS NOT NULL AND plant_date >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AND plant_date < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY) GROUP BY plant_month, species, care_taker, address, site_info
  1. Click on the Schedule button, then Create new scheduled query.

The Create new scheduled query option highlighted in the expanded Schedule menu

  1. On the new Scheduled query page, set the following:

  • Name: Update_trees_daily

  • Schedule options:

    • Repeats: daily, choose date and time in the future
  1. In the Destination for query results sections, check the box for Set a destination table for query results and specify dataset name as Reports.

  • Table name: type in "Trees" and select Append to table so it doesn't overwrite existing data.

The New Scheduled Query dialog box displaying the updated details

  1. Click Save.

  2. You may have a popup blocker enabled, click Allow and then give your lab credentials permission, then agree to replace your query.

Note: If you run this query, you won't see any new results because they haven't happened yet.

Task 5. Create new data sources in Data Studio

Now you'll build your dashboard using the tree data you've just aggregated with Data Studio.

  1. Open a new tab in your browser and go to Data Studio.

  2. Click Create in the top left, and then click Report.

  3. Enter the country and check the terms and conditions.

  4. Click Continue.

  5. Select No for all email offers, and then click Continue.

Task 6. Create a new report in Data Studio

  1. Click on the BigQuery, then click Authorize.

Now you'll use the BigQuery connector to connect to the reports.trees table.

  1. Start by selecting your Qwiklabs project, then the Reports dataset, then the Trees table, as shown below:

The selected project, dataset, and table on the Add data to report page

  1. Click Add and then click Add to Report.

Click Check my progress to verify the objective. Create new data sources in Data Studio

Now you can create charts using the data in this table.

  1. Click on Add a chart dropdown and select the type you want. In this example, you can see the following types of charts:

    • Stacked column bar graph showing the number of trees planted each month and the name of the caretaker who planted them.
    • A scorecard showing the total number of trees added in the last year.
    • A pie chart showing the percent distribution of trees planted by their species.
    • A table chart along with a bar graph representing the number of trees planted by site.

An example of the various types of charts displayed

You can experiment on your own creating charts and titles modeled after the example. Here are some hints:

  • Titles are created using the text tool. In the example, titles were created for each chart and the dashboard itself.

  • When a chart is selected, you can edit the colors and font sizes when you click on the Style tab on the right-hand side.

  • Click on a chart to modify its size and drag it to a new location.

Congratulations!

You've learned how to build a BI dashboard for visualizing patterns in your business data with less risk of expensive query volumes.

Finish your quest

This self-paced lab is part of the BigQuery for Marketing Analysts quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in this quest and get immediate completion credit. Refer to the Google Cloud Skills Boost catalog for all available quests.

Next steps / learn more

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated Sptemeber 8, 2022

Lab Last Tested May 2, 2022

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.