Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Dashboard Parameters Video Script

Joe Allan Muharsky edited this page Feb 28, 2016 · 1 revision

Parameterizing a dashboard

Describes how to add parameters to a dashboard, set their default values, and update them via widget linking. Also explains how parameters are passed via URL.

Create a new Dashboard

Add a widget with a custom SQL statement

SELECT year, COUNT(*) AS count FROM publicdata:samples.natality WHERE year > 2000 AND state IS NOT NULL GROUP BY year

  • Notice that the query returns the per-year total for each state.

Add a WHERE constraint to show only 'AK'

SELECT year, COUNT(*) AS count FROM publicdata:samples.natality WHERE year > 2000 AND state IS NOT NULL AND REGEXP_MATCH(state, 'AK') GROUP BY year

  • Notice that the query now returns totals only for Arkansas.

Add a Dashboard Parameter for the State filter

  • Click on the Dashboard tab.
  • In the Parameters section, click in the empty box with the 'click to add' label.
  • Add a parameter with the name 'STATE' and a default value of 'AK'.
  • Modify the SQL statement to replace the string 'AK' with the token '%%STATE%%', ex:

SELECT year, COUNT(*) AS count FROM publicdata:samples.natality WHERE year > 2000 AND state IS NOT NULL AND REGEXP_MATCH(state, '%%STATE%%') GROUP BY year

  • Refresh the query. Notice that the query result is unchanged.

Surface the Parameter value on the Dashboard and Widget titles.

  • Change the Dashboard title to include the token string, ex:

    Natality Statistics for US State (%%STATE%%)

    • Notice that the Dashboard title changes to show AK instead of %%STATE%%
  • Change the Widget title to include the token string, ex:

    Births By Year for %%STATE%%

    • Notice that the Widget title changes to show AK instead of %%STATE%%

Modify the parameter defaults

  • Open the Dashboard tab.
  • Change the string AK to OH.
    • Notice that the Dashboard and Widget titles update automatically as you change the value.
  • Click the Refresh button on the widget
    • Notice that the query results now reflect statistics for Ohio.

Change Parameter values via the URL

  • Save the Dashboard if you haven't already.
  • In the page URL, add a querystring parameter that maps to your dashboard parameter, and set the value to FL. Ex:

https://perfkit-explorer.appspot.com/explore?dashboard=25&STATE=FL

  • Open the URL (press ENTER or click the browser's Refresh button)
    • Notice that the Dashboard and Widget title, as well as the query result, reflect the FL value.
  • Open the Dashboard tab, and notice that the parameter default is still set to OH.

Change Parameter values via Widget Links

  • Add a new container, and move it to the top of the page.
  • Open the Widget tab, and set the URL property to the current dashboard with no STATE parameter set, ex:

https://perfkit-explorer.appspot.com/explore?dashboard=25

  • Add a second widget, and set its URL to the current dashboard with the STATE parameter set to CA, ex:

https://perfkit-explorer.appspot.com/explore?dashboard=25&STATE=CA

  • Save the Dashboard.
  • Click the URL on the first widget. Notice that the page reloads with the state set to AK.
  • Click the URL on the second widget. Notice that the page reloads for CA.