Assignment: Build Two Dashboards
This page is optional. Nothing here is required for Week 11's learning goals or the assignment.
Use these resources to go deeper on Metabase, Streamlit, or metric definitions after the assignment is complete.
{{variable}} in SQL mode: covers date filters, category filters, and optional clauses. Needed if you want the Extra tier's date filter on fct_trips.st.line_chart, you can render st.area_chart, st.bar_chart, and hand off to Altair or Plotly for custom visuals.#general and course channels often discuss the tools covered this week.If you want to add interactive date filters to a Metabase dashboard where the questions are built with raw SQL queries, you cannot just drag-and-drop a filter chip. Since SQL queries are native blocks of code, Metabase does not automatically know how to apply filters to them.
To make this work:
Step 1: add a template variable to the SQL. Edit your SQL query and define a variable, using the double-brace {{variable_name}} syntax:
SELECT pickup_borough, COUNT(*) AS trip_count
FROM nyc_taxi_reference.fct_trips
-- A template variable must stand alone, Metabase replaces it with the full clause:
WHERE {{pickup_date}}
GROUP BY pickup_borough
Step 2: configure the variable type as a Field Filter. In the right-hand variables panel of the query editor, click your variable. Change its Variable type to Field Filter, map the Field to filter to the matching column in the database (e.g. team1.nyc_taxi_reference.fct_trips.pickup_datetime), and save the question.
Step 3: add the filter to the Dashboard. Open your dashboard, click Edit, then click Add a filter → Date picker → Date range. Click the filter chip, then map it to the Question card by selecting the pickup_date field filter variable, and save the dashboard.
(For a full guide, see the Metabase Field Filters documentation.)
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

Built with ❤️ by the HackYourFuture community · Thank you, contributors
Found a mistake or have a suggestion? Let us know in the feedback form.