-
Notifications
You must be signed in to change notification settings - Fork 64
Dashboard Parameters Video Script
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.
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.
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.
- 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.
-
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%%
- 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.
- 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.
- 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.