Skip to content

Instantly share code, notes, and snippets.

@hotdogee
Created September 15, 2024 06:11
Show Gist options
  • Save hotdogee/199f168d116e57a0852c2b3cefded35f to your computer and use it in GitHub Desktop.
Save hotdogee/199f168d116e57a0852c2b3cefded35f to your computer and use it in GitHub Desktop.
GSP346 - Prepare Data for Looker Dashboards and Reports: Challenge Lab

GSP346 - Prepare Data for Looker Dashboards and Reports: Challenge Lab - 1 hour - Introductory

  • Skill Badge: Prepare Data for Looker Dashboards and Reports

https://www.cloudskillsboost.google/games/5429/labs/35216

  • Click "Open Looker" and log in
  • Development mode
  • Develop -> qwiklabs-flights
  • + Icon -> Create Dashboard -> lab
    • Generate the LookML Code (check below)
    • Paste the generated LookML Code
  • Open general/flights/faa.model
    • /projects/qwiklabs-flights/files/general/flights/faa.model.lkml
    • Add to line 5
    • include: "/*.dashboard.lookml"
      explore: +flights {
        query: Task_2_Part_1 {
          dimensions: [aircraft_origin.city, aircraft_origin.code, aircraft_origin.state]
          measures: [count]
        }
      }
      explore: +airports {
        query: Task_2_Part_2 {
          dimensions: [city, code, state]
          filters: [
            airports.control_tower: "Yes",
            airports.is_major: "Yes",
            airports.joint_use: "Yes"
          ]
        }
      }
      
    • Save Changes -> Validate LookML -> Commit Changes & Push -> Randomly type a Message -> Commit -> Deploy to Production
  • Task 2
  • Explore -> Flights -> Quick Start -> Task 2 Part 1
    • /explore/faa/flights
    • Row Limit: 10 (Not Required: Tested)
    • Gear Icon -> Merge results
    • Explore -> Airports -> Quick Start -> Task 2 Part 2
      • Row Limit: 10 (Not Required: Tested)
      • Save
    • Visualization: Bar (Required: Tested)
    • Gear -> Save to Dashboard...
      • Title: Busiest, Major Joint-Use Airports with Control Towers (Not Required: Tested)
      • New Dashboard - Shared
        • Copy and paste the title from BOARD_NAME (Required: Tested)
        • OK
      • Save to Dashboard
    • FINISH: Checkpoint 2
  • Task 3
    • Folders -> LookML Dashboards
      • Import... -> Developer Student -> OK
    • FINISH: Checkpoint 3
  • Task 1
    • My folder -> Click into dashboard -> Edit dashboard -> For each Look Tile
      • Tile Action -> Edit
        • Gear -> Save... -> As a Look ->
      • Right click -> Open in new tab on Explore from here on the four Looks
        • Title will be auto filled with the correct value
    • FINISH: Checkpoint 1

Generate the LookML Code in a bash shell

# Extract Export Variables from the lab page
export COUNT="10"
export COUNT_1="6"
export DASHBOARD_NAME="Plane and Helicopter Rental Hub Board"
export COUNT=
export COUNT_1=
export DASHBOARD_NAME=
###
cat > ${DASHBOARD_NAME}_${COUNT}_${COUNT_1}.lkml << EOF
- dashboard: plane_and_helicopter_rental_hub_details
  title: $DASHBOARD_NAME
  layout: newspaper
  preferred_viewer: dashboards-next
  elements:
  - name: Busiest, Major Joint-Use Airports with Control Towers
    title: Busiest, Major Joint-Use Airports with Control Towers
    merged_queries:
    - model: faa
      explore: flights
      type: looker_column
      fields: [aircraft_origin.city, aircraft_origin.state, aircraft_origin.code,
        flights.count]
      limit: 10
      x_axis_gridlines: false
      y_axis_gridlines: true
      show_view_names: false
      show_y_axis_labels: true
      show_y_axis_ticks: true
      y_axis_tick_density: default
      y_axis_tick_density_custom: 5
      show_x_axis_label: true
      show_x_axis_ticks: true
      y_axis_scale_mode: linear
      x_axis_reversed: false
      y_axis_reversed: false
      plot_size_by_field: false
      trellis: ''
      stacking: ''
      limit_displayed_rows: false
      legend_position: center
      point_style: none
      show_value_labels: false
      label_density: 25
      x_axis_scale: auto
      y_axis_combined: true
      ordering: none
      show_null_labels: false
      show_totals_labels: false
      show_silhouette: false
      totals_color: "#808080"
      defaults_version: 1
    - model: faa
      explore: airports
      type: table
      fields: [airports.state, airports.city, airports.code]
      filters:
        airports.control_tower: 'Yes'
        airports.is_major: 'Yes'
        airports.joint_use: 'Yes'
      sorts: [airports.state]
      limit: 10
      join_fields:
      - field_name: airports.state
        source_field_name: aircraft_origin.state
      - field_name: airports.city
        source_field_name: aircraft_origin.city
      - field_name: airports.code
        source_field_name: aircraft_origin.code
    type: looker_bar
    series_types: {}
    row:
    col:
    width:
    height:
  - title: Facility Type Breakdown for Top $COUNT States
    name: Facility Type Breakdown for Top $COUNT States
    model: faa
    explore: airports
    type: looker_grid
    fields: [airports.facility_type, airports.state, airports.count]
    pivots: [airports.facility_type]
    sorts: [airports.count desc 0, airports.facility_type]
    limit: $COUNT
    column_limit: 50
    show_view_names: false
    show_row_numbers: true
    transpose: false
    truncate_text: true
    hide_totals: false
    hide_row_totals: false
    size_to_fit: true
    table_theme: white
    limit_displayed_rows: false
    enable_conditional_formatting: false
    header_text_alignment: left
    header_font_size: 12
    rows_font_size: 12
    conditional_formatting_include_totals: false
    conditional_formatting_include_nulls: false
    map_plot_mode: points
    heatmap_gridlines: false
    heatmap_gridlines_empty: false
    heatmap_opacity: 0.5
    show_region_field: true
    draw_map_labels_above_data: true
    map_tile_provider: light
    map_position: fit_data
    map_scale_indicator: 'off'
    map_pannable: true
    map_zoomable: true
    map_marker_type: circle
    map_marker_icon_name: default
    map_marker_radius_mode: proportional_value
    map_marker_units: meters
    map_marker_proportional_scale_type: linear
    map_marker_color_mode: fixed
    show_legend: true
    quantize_map_value_colors: false
    reverse_map_value_colors: false
    defaults_version: 1
    series_types: {}
    listen: {}
    row:
    col:
    width:
    height:
  - title: 'States and Cities with Highest Percentage of Cancellations: Flights over
      10,000'
    name: 'States and Cities with Highest Percentage of Cancellations: Flights over
      10,000'
    model: faa
    explore: flights
    type: looker_grid
    fields: [aircraft_origin.city, aircraft_origin.state, flights.cancelled_count,
      flights.count]
    filters:
      flights.count: ">10000"
    sorts: [percentage_of_flights_cancelled desc]
    column_limit: 50
    dynamic_fields: [{category: table_calculation, expression: "\${flights.cancelled_count}/\${flights.count}",
        label: Percentage of Flights Cancelled, value_format: !!null '', value_format_name: !!null '',
        _kind_hint: measure, table_calculation: percentage_of_flights_cancelled, _type_hint: number}]
    show_view_names: false
    show_row_numbers: true
    transpose: false
    truncate_text: true
    hide_totals: false
    hide_row_totals: false
    size_to_fit: true
    table_theme: white
    limit_displayed_rows: false
    enable_conditional_formatting: false
    header_text_alignment: left
    header_font_size: 12
    rows_font_size: 12
    conditional_formatting_include_totals: false
    conditional_formatting_include_nulls: false
    map_plot_mode: points
    heatmap_gridlines: false
    heatmap_gridlines_empty: false
    heatmap_opacity: 0.5
    show_region_field: true
    draw_map_labels_above_data: true
    map_tile_provider: light
    map_position: fit_data
    map_scale_indicator: 'off'
    map_pannable: true
    map_zoomable: true
    map_marker_type: circle
    map_marker_icon_name: default
    map_marker_radius_mode: proportional_value
    map_marker_units: meters
    map_marker_proportional_scale_type: linear
    map_marker_color_mode: fixed
    show_legend: true
    quantize_map_value_colors: false
    reverse_map_value_colors: false
    defaults_version: 1
    series_types: {}
    listen: {}
    row:
    col:
    width:
    height:
  - title: Top $COUNT Cities With Most Heliports
    name: Top $COUNT Cities With Most Heliports
    model: faa
    explore: airports
    type: looker_map
    fields: [airports.city, airports.state, airports.count]
    filters:
      airports.facility_type: 'HELIPORT^ ^ ^ ^ ^ ^ ^ '
    sorts: [airports.count desc]
    limit: $COUNT
    column_limit: 50
    map_plot_mode: points
    heatmap_gridlines: false
    heatmap_gridlines_empty: false
    heatmap_opacity: 0.5
    show_region_field: true
    draw_map_labels_above_data: true
    map_tile_provider: light
    map_position: fit_data
    map_scale_indicator: 'off'
    map_pannable: true
    map_zoomable: true
    map_marker_type: circle
    map_marker_icon_name: default
    map_marker_radius_mode: proportional_value
    map_marker_units: meters
    map_marker_proportional_scale_type: linear
    map_marker_color_mode: fixed
    show_view_names: false
    show_legend: true
    quantize_map_value_colors: false
    reverse_map_value_colors: false
    defaults_version: 1
    listen: {}
    row:
    col:
    width:
    height:
  - title: Top $COUNT_1 Airports With Smallest Average Distance
    name: Top $COUNT_1 Airports With Smallest Average Distance
    model: faa
    explore: flights
    type: looker_grid
    fields: [flights.origin_and_destination, average_distance_miles]
    filters:
      average_distance_miles: ">0"
    sorts: [average_distance_miles]
    limit: $COUNT_1
    dynamic_fields: [{category: measure, expression: !!null '', label: Average Distance
          (Miles), value_format: !!null '', value_format_name: !!null '', based_on: flights.average_distance,
        _kind_hint: measure, measure: average_distance_miles, type: average, _type_hint: number}]
    show_view_names: false
    show_row_numbers: true
    transpose: false
    truncate_text: true
    hide_totals: false
    hide_row_totals: false
    size_to_fit: true
    table_theme: white
    limit_displayed_rows: false
    enable_conditional_formatting: false
    header_text_alignment: left
    header_font_size: 12
    rows_font_size: 12
    conditional_formatting_include_totals: false
    conditional_formatting_include_nulls: false
    map_plot_mode: points
    heatmap_gridlines: false
    heatmap_gridlines_empty: false
    heatmap_opacity: 0.5
    show_region_field: true
    draw_map_labels_above_data: true
    map_tile_provider: light
    map_position: fit_data
    map_scale_indicator: 'off'
    map_pannable: true
    map_zoomable: true
    map_marker_type: circle
    map_marker_icon_name: default
    map_marker_radius_mode: proportional_value
    map_marker_units: meters
    map_marker_proportional_scale_type: linear
    map_marker_color_mode: fixed
    show_legend: true
    quantize_map_value_colors: false
    reverse_map_value_colors: false
    defaults_version: 1
    series_types: {}
    listen: {}
    row:
    col:
    width:
    height:
EOF
cat dashboard.lkml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment