Skip to Main Content

Dahlgren Memorial Library

Creating Dashboards with Google Data Studio

Use this guide to follow along during DML's Google Data Studio Workshop

Connect to BigQuery

In your Data Studio Dashboard, click the "+Create" button at the top left. Select "Data Source". 

add a new data source

Select "BigQuery" from the list of Google Connectors.

select BigQuery Connector

If this is your first time connecting Data Studio to BigQuery, click the "Authorize" button to authorize the connection. 

authorize BigQuery

Select Custom Query -- Your billing project -- and paste in the SQL code below to add data for Washington, D.C. Then click the "add" button to connect. The process of connecting data will be done a total of 3 times if you want to include data from Maryland and Virginia in your dashboard. See the box at the bottom of the page for code for each state. 

select
    ct.state_fips_code,
    ct.county_fips_code,
    c.county_name,
    ct.tract_ce,
    ct.geo_id,
    ct.tract_name,
    ct.lsad_name,
    ct.internal_point_lat,
    ct.internal_point_lon,
    ct.internal_point_geo,
    ct.tract_geom,
    acs.total_pop,
    acs.households,
    acs.male_pop,
    acs.female_pop,
    acs.median_age,
    acs.median_income,
    acs.income_per_capita,
    acs.gini_index,
    acs.owner_occupied_housing_units_median_value,
    acs.median_rent,
    acs.percent_income_spent_on_rent,
from `bigquery-public-data.geo_census_tracts.census_tracts_district_of_columbia` ct
left join `bigquery-public-data.geo_us_boundaries.counties` c
    on (ct.state_fips_code || ct.county_fips_code) = c.geo_id
left join `bigquery-public-data.census_bureau_acs.censustract_2018_5yr` acs
    on ct.geo_id = acs.geo_id

Verify the data fields being imported. Change the "province_state" datat type from "text" to "Geo--Region". Click "Create Report" once you have confirmed the data types. 

verifycensusdatafields

SQL Code for DMV Sources

select
    ct.state_fips_code,
    ct.county_fips_code,
    c.county_name,
    ct.tract_ce,
    ct.geo_id,
    ct.tract_name,
    ct.lsad_name,
    ct.internal_point_lat,
    ct.internal_point_lon,
    ct.internal_point_geo,
    ct.tract_geom,
    acs.total_pop,
    acs.households,
    acs.male_pop,
    acs.female_pop,
    acs.median_age,
    acs.median_income,
    acs.income_per_capita,
    acs.gini_index,
    acs.owner_occupied_housing_units_median_value,
    acs.median_rent,
    acs.percent_income_spent_on_rent,
from `bigquery-public-data.geo_census_tracts.census_tracts_district_of_columbia` ct
left join `bigquery-public-data.geo_us_boundaries.counties` c
    on (ct.state_fips_code || ct.county_fips_code) = c.geo_id
left join `bigquery-public-data.census_bureau_acs.censustract_2018_5yr` acs
    on ct.geo_id = acs.geo_id

select
    ct.state_fips_code,
    ct.county_fips_code,
    c.county_name,
    ct.tract_ce,
    ct.geo_id,
    ct.tract_name,
    ct.lsad_name,
    ct.internal_point_lat,
    ct.internal_point_lon,
    ct.internal_point_geo,
    ct.tract_geom,
    acs.total_pop,
    acs.households,
    acs.male_pop,
    acs.female_pop,
    acs.median_age,
    acs.median_income,
    acs.income_per_capita,
    acs.gini_index,
    acs.owner_occupied_housing_units_median_value,
    acs.median_rent,
    acs.percent_income_spent_on_rent,
from `bigquery-public-data.geo_census_tracts.census_tracts_virginia` ct
left join `bigquery-public-data.geo_us_boundaries.counties` c
    on (ct.state_fips_code || ct.county_fips_code) = c.geo_id
left join `bigquery-public-data.census_bureau_acs.censustract_2018_5yr` acs
    on ct.geo_id = acs.geo_id

select
    ct.state_fips_code,
    ct.county_fips_code,
    c.county_name,
    ct.tract_ce,
    ct.geo_id,
    ct.tract_name,
    ct.lsad_name,
    ct.internal_point_lat,
    ct.internal_point_lon,
    ct.internal_point_geo,
    ct.tract_geom,
    acs.total_pop,
    acs.households,
    acs.male_pop,
    acs.female_pop,
    acs.median_age,
    acs.median_income,
    acs.income_per_capita,
    acs.gini_index,
    acs.owner_occupied_housing_units_median_value,
    acs.median_rent,
    acs.percent_income_spent_on_rent,
from `bigquery-public-data.geo_census_tracts.census_tracts_maryland` ct
left join `bigquery-public-data.geo_us_boundaries.counties` c
    on (ct.state_fips_code || ct.county_fips_code) = c.geo_id
left join `bigquery-public-data.census_bureau_acs.censustract_2018_5yr` acs
    on ct.geo_id = acs.geo_id