What you will be able to do
- Summarize a column's center and spread with MEDIAN and STDDEV, and predict what they return for even counts, NULLs and single rows
- Read a worksheet result with the inspector's contextual statistics and chart aggregations, and know which result transformations cost compute
- Pass results between SQL and Python cells in a Snowflake Notebook and chart them inline
- Lay out dashboard tiles so they describe a dataset at a glance, including several views of one query
- Drive every tile from one control with :daterange and :datebucket, and define a reusable custom filter that compares segments
Key concept
Descriptive analysis — Describing what a dataset looks like now: how many rows, where the values center, how widely they spread, and which values come up most often. In Snowflake you do it ad hoc in a worksheet or notebook, then keep it on a dashboard where filters change the slice without anyone editing SQL.
1.Center and spread with SQL aggregates
Descriptive analysis is usually the first thing you do with a dataset, before you diagnose or forecast anything. You answer what is in the data: how many rows there are, what a typical value is, and how far values stray from it. A SQL worksheet is the quickest place to start. Set a database and schema as the worksheet context, and the ad-hoc statements that follow can name tables without qualifying them. When an analyst writes SALES_DB.PUBLIC.ORDERS over and over, the context selector is the fix.
MEDIAN gives you a center that outliers can't drag around. It takes a numeric expression and ignores NULLs. With an odd number of non-NULL values it returns the middle one. With an even number it returns the average of the two middle values, so for 1, 3, 5 and 20 the answer is 4. If every value is NULL, or there are no rows, it returns NULL. MEDIAN(DISTINCT v) is not allowed. MEDIAN also works as a window function with PARTITION BY, but the OVER clause can't contain an ORDER BY or an explicit window frame.
INSERT INTO aggr VALUES (1, 10), (1, 20), (1, 21);
INSERT INTO aggr VALUES (2, 10), (2, 20), (2, 25), (2, 30);
INSERT INTO aggr VALUES (3, NULL);STDDEV and STDDEV_SAMP are two names for one function. Both return the sample standard deviation of non-NULL values as a DOUBLE. If you want the population version, use STDDEV_POP. Unlike MEDIAN, STDDEV accepts DISTINCT. A VARCHAR argument is implicitly cast to floating point, and the query errors if that cast fails. The single-record NULL catches people out in segment summaries: a region with one order shows a blank spread, not a zero. It also differs from Oracle, where STDDEV returns 0 for a single record.
Checkpoint 1 of 9· Check yourself
An analyst exploring order data in a SQL worksheet keeps typing SALES_DB.PUBLIC.ORDERS in every ad-hoc MEDIAN and STDDEV query. What lets them write just ORDERS instead?
Once a database and schema are set as the worksheet context, the worksheet's queries can name objects in that schema without the database and schema prefix. Choosing a warehouse only decides what compute runs the query. It does not change how table names resolve.
“as the worksheet context, you can reference objects in the schema without fully qualifying the object names in your query.”Source: docs.snowflake.com
2.Reading a result with the worksheet inspector
Some questions don't need a single aggregate query. After SELECT * FROM customers, you can select a column, a range of cells or whole rows in the results table, and the inspector pane on the right fills with statistics for that selection. It gives an overview of every column, and selecting a column header opens that column's detailed statistics. You can also filter the result by clicking items in the pane.
| Column type | Statistic shown | What it tells you |
|---|---|---|
| Every column | Filled/empty meter | How many rows are populated, plus invalid rows for types such as email and JSON |
| Date, time, numeric | Histogram | How many rows fall in each range. Click a bar or drag across it to select a range |
| Categorical (text with repeated values) | Frequency distribution | Which values are most common |
| Email domain distribution | How often each domain name occurs | |
| JSON | Key distribution | The top keys across rows, or the relative value types if the column holds arrays |
Statistics are generated for results of up to 1 million rows. So the spread of signup_date comes from its histogram and the common values of plan_tier from its frequency distribution, with no extra query. Accounts in U.S. government regions, VPS accounts, and accounts on Private Connectivity still have results capped at 10,000 rows.
Changing the result can cost compute. Sorting a column from its column options applies to the whole result, not just the rows on screen, and runs on the same warehouse as the original query. Display-only changes are free: a thousands separator, percentage display, decimal precision, and date or timestamp formatting. To find the transformations that did run, filter Query History for SQL text containing snowsight_transform_cte.
Selecting Chart turns the same result into a bar chart, line chart, scatterplot, heat grid or scorecard. When a chart buckets data, for example daily rows rolled up to weeks or months, or numbers grouped into integer buckets, it collapses each bucket to one value with an aggregation: average, count, minimum, maximum, median, mode or sum. These are chart settings, so you can change the summary without touching the SQL. A query shows one chart type at a time.
Checkpoint 2 of 9· Match them up
After you run SELECT * FROM customers in a worksheet, the inspector pane shows a different statistic for each column type. Match each column type to the statistic it gets.
Tap a term, then the definition that fits it.
The inspector picks its statistic from the column type. Date, time and numeric columns get histograms. Categorical text columns get frequency distributions. Email columns get domain distributions, and JSON columns get key distributions. Every column also shows a filled/empty meter.
“Displayed for all categorical columns. Categorical columns are text columns where the same values are used more than once.”Source: docs.snowflake.com
3.Exploratory analysis in Snowflake Notebooks
Use a notebook when the analysis mixes languages. You might pull a monthly summary in SQL, reshape it in pandas, chart it, and write notes beside the result. A notebook holds Python, SQL and Markdown cells in one document that runs cell by cell. In the warehouse runtime it comes with pandas, numpy, Snowpark, Streamlit and Altair already installed. In the newest accounts, the next-generation version of this experience runs inside Workspaces.
Cells pass results by name. The name of a SQL cell becomes a Python object in later cells: cell1.to_df() returns a Snowpark DataFrame and cell1.to_pandas() returns a pandas DataFrame. Going the other way, a SQL cell references a Python variable or another SQL cell with double braces. Names are case-sensitive and must exactly match the cell you mean.
| From | Into | Syntax | Example |
|---|---|---|---|
| SQL cell | Python cell | cell name | my_df = cell1.to_pandas() |
| SQL cell | SQL cell | {{cell2}} | SELECT * FROM {{cell2}} where PRICE > 500 |
| Python string used as a value | SQL cell | '{{variable}}' in quotes | SELECT * FROM my_table WHERE COUNTRY = '{{c}}' |
| Python string used as an identifier | SQL cell | {{variable}} without quotes | SELECT * FROM my_table WHERE {{column_name}} = 'USA' |
References into SQL work only with Python strings. A pandas or Snowpark DataFrame can't be placed inside {{ }}. If a filtered DataFrame needs to go back to SQL, persist it or rebuild it as a query. Don't try to template it in.
Charts render directly under the cell. Altair is the shortest route because it is imported by default as part of Streamlit, so a SQL result converted with to_pandas() can go straight into alt.Chart. Streamlit chart elements such as st.bar_chart also work with no setup. Matplotlib, plotly and seaborn must first be added from the notebook's Packages menu, and adding a package means restarting the session.
import altair as alt
alt.Chart(df).mark_bar().encode(
x= alt.X("measurement", axis = alt.Axis(labelAngle=0)),
y="value",
color="species"
)Output limits affect what you see, not what you can compute. A DataFrame displays at most 10,000 rows or 8 MB, whichever is lower, but the whole DataFrame stays in the session for later cells. A single cell's output is capped at 20 MB and is dropped above that, so split heavy output across cells.
Checkpoint 3 of 9· Check yourself
A Python cell builds a DataFrame of 2 million rows, and the notebook shows only the first 10,000. What is true of the rest of the data?
The display limit trims what is rendered in the cell result, not the DataFrame itself. The full DataFrame remains in the session, so later transformations still operate on all rows.
“However, the entire DataFrame is still available in the notebook session for use.”Source: docs.snowflake.com
4.Summary tiles that describe a dataset at a glance
A dashboard is where a descriptive summary lives once the ad-hoc work is done. Snowsight dashboards built from tiles arrange chart and table tiles, each driven by its own query. For a descriptive dashboard, put the headline numbers (row count, median order value, spread) in scorecard tiles along the top. Put distributions in bar charts or heat grids below them. Drag tiles into that order, since new tiles always land at the bottom.
Because one query shows one chart type, two views of the same result need two tiles. For a table tile, open Edit Query, select Chart, and return to the dashboard. That adds a chart tile built from the same query at the bottom. Duplicate Tile copies a tile, and you can then give the copy a different chart. Moving a worksheet onto a dashboard takes it out of the worksheet list, and anyone it was shared with loses access.
| Action | Tile | Underlying query |
|---|---|---|
| Unplace Tile | Removed from the layout, but still available from the Add tile menu | Kept |
| Delete | Removed permanently, along with any other tile built on the same query | Deleted, cannot be undone |
Dashboard queries run in their own sessions with an assigned role and warehouse, set in the dashboard's context selector. Run refreshes every tile. To view a shared dashboard, a user needs the same role as those sessions, and dashboards always run with the user's primary role, never secondary roles.
Checkpoint 4 of 9· Check yourself
On a descriptive dashboard, a table tile showing median order value also feeds a chart tile, created through Edit Query > Chart. The owner wants the table tile off the layout for now and may want it back next quarter. The chart tile must keep working. Which action fits?
Unplace Tile takes the tile off the layout but keeps its query, so you can add the tile back from the Add tile menu. Delete removes the query permanently, and because the chart tile uses that same query, deleting the table tile would remove the chart tile too.
“select Unplace Tile. The tile is removed from the dashboard, but remains available to add to the dashboard from the Add tile menu.”Source: docs.snowflake.com
Sources8
5.One date control for every tile
Filters let viewers re-slice a dashboard without editing SQL: a keyword such as :daterange sits in the query, and the viewer's dropdown choice decides what it becomes. Snowflake resolves the keyword to a subquery or a list of values before the query runs. A selected item turns the predicate into <col> = <item>, several items into <col> IN (...), and an All option into true. That rewrite is why the pattern is rigid. A filter works only as the right side of an equals comparison, such as WHERE O_ORDERDATE = :daterange, or in a SELECT list as :datebucket(col). LIKE and CONTAINS fail, and a filter can't be used inside a stored procedure or a UDF. Stick to column = :keyword in tiles. Every role gets two system filters, and they can't be edited or dropped.
:daterange filters a column to a window such as Last day, Last 7 days, Last 28 days, Last 3 months, Last 12 months, All time, or a custom range. It defaults to Last day and always uses UTC, whatever TIMESTAMP_INPUT_FORMAT is set to. :datebucket groups aggregates by Second, Minute, Hour, Day, Week, Month, Quarter or Year, and defaults to Day.
SELECT
COUNT(O_ORDERDATE) as orders, O_ORDERDATE as date
FROM
SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS
WHERE
O_ORDERDATE = :daterange
GROUP BY
:datebucket(O_ORDERDATE), O_ORDERDATE
ORDER BY
O_ORDERDATE
LIMIT 10;When six tiles each contain = :daterange, one change of the date control reruns all six over the new window. Hard-coded BETWEEN boundaries, session variables and per-period views all mean someone edits SQL or repoints tiles every time. Filter values have two buttons. Apply reruns with a value just for you, for example to look across All time once. Save stores the value as the default that viewers get, so you can keep a cheap Last 7 days as the starting point.
Checkpoint 5 of 9· Fill the gap
A dashboard has six tiles, and all of them should move together when a viewer changes the single date-range control. Which keyword completes the WHERE predicate that each tile's query needs?
SELECT
COUNT(O_ORDERDATE) as orders, O_ORDERDATE as date
FROM
SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS
WHERE
O_ORDERDATE = ?
GROUP BY
:datebucket(O_ORDERDATE), O_ORDERDATE
ORDER BY
O_ORDERDATE
LIMIT 10;The :daterange system filter limits a column to the window chosen in the dashboard's date control, so putting = :daterange in every tile's query reruns all of them over the new window. :datebucket only sets how aggregates are grouped. {{ }} is how notebook cells reference each other, and $daterange would be a session variable that someone has to change by editing SQL.
Checkpoint 6 of 9· Exam question
A retail analyst has a Snowsight dashboard with six tiles that all filter orders by order date. Managers want one control that changes the date window for every tile without anyone editing SQL. What should the analyst do?
Correct answer: A — Add the system filter :daterange to each tile query's WHERE clause so a single dashboard control drives the date window on every tile
- A. The built-in
:daterangesystem filter is available in every account and, once referenced in each tile query, one control on the dashboard changes the window for all of them without SQL edits. - B. Session variables are scoped to one worksheet session and are not exposed as a dashboard control. Managers would still have to edit SQL, which the requirement forbids.
- C. Views are static definitions, so every window change means DDL and re-pointing tiles. A filter keyword is the intended interactive mechanism.
- D. Hard-coded boundaries multiply dashboards and maintenance, and users still cannot change the window interactively from one control.
Sources9
6.A reusable filter for comparing segments
A custom filter answers questions like "how does the median basket in EMEA compare with APAC?" without a second query. Custom filters work like the system ones: write WHERE region = :region once in each tile, then switch segments from a dropdown and watch every statistic recompute. A custom filter is defined once for the whole account. Anyone in the account can see and use it on any dashboard or worksheet, and the role attached to it does not limit who sees it.
Only certain roles can create filters. An ACCOUNTADMIN grants filter-creation permission to roles, and only in Snowsight. A filter is defined in the Filters dialog (Manage Filters in a worksheet) and needs these settings:
| Setting | What to enter |
|---|---|
| Display Name | The label viewers see on the filter |
| SQL Keyword | A unique keyword in the form :<string> with no spaces, for example :region |
| Role | A role allowed to create filters. It runs the options query |
| Warehouse | Refreshes query-based options. The filter's role needs USAGE on it |
| Options via | Query (returns name and value, optionally description, one row per option) or List (name/value pairs typed in, Text or Number) |
| Toggles | Multiple values can be selected; include an All option; include an Other option |
A query-based filter can run only one query, so name and value must come from the same statement. That query runs as the user who created or last changed the filter, and every account user can see the dropdown, so keep sensitive values out of it. The option list refreshes hourly by default, or daily or never. The schedule spends warehouse credits even when nobody has the filter open, so a region list that rarely changes should refresh daily or never.
Checkpoint 7 of 9· Match them up
You're defining a region filter in the Snowsight Filters dialog so that every tile can switch between EMEA and APAC. Match each setting to what it controls.
Tap a term, then the definition that fits it.
Each tile references the filter through its SQL keyword. The values come from a query or a typed list, and the warehouse refreshes them. The role only runs the options query. Anyone in the account can see and use a custom filter, so the role is not an access control.
“select a role to associate with the filter and run the query used to populate filter values”Source: docs.snowflake.com
Checkpoint 8 of 9· Exam question
An analyst creates a query-based custom filter in Snowsight so dashboard viewers can pick a product category from a dropdown. Which two requirements must hold for the filter's options to populate correctly? Select TWO.(Select 2)
Correct answers: C, D — The source query returns name and value columns, plus an optional description column, with one row per selectable category; The filter is associated with a role and a warehouse, and that role holds USAGE on the warehouse that runs the options query
- A. Snowsight reads rows, not column headers, as options, so a pivoted single row does not map to the expected pair.
- B. The keyword and display name are entered in the filter dialog and are not columns of the options query.
- C. Query-based custom filters read the dropdown from columns named
nameandvalue, and optionallydescription. - D. The options query executes on compute, so the owning role needs warehouse USAGE for the list to populate.
- E. The column names are not free-form: the filter needs
nameandvalue, so a lonecategorycolumn does not match.
Checkpoint 9 of 9· Exam question
A team wants a reusable custom filter so analysts can restrict any tile to one region. Which statements about defining and using the filter are correct? Select TWO.(Select 2)
Correct answers: C, D — The filter gets a SQL keyword in the form :region, which tile queries reference in a predicate such as WHERE region = :region; The filter's options can come from a SQL query returning name and value columns or from a manually entered list of values
- A. Custom filters are account-level objects that can be used on worksheets and dashboards, so they are not recreated per dashboard.
- B. Filter syntax is equality-based, using
= :keywordor the function form, and it does not support arbitrary comparison operators. - C. Custom filters are referenced by a unique keyword prefixed with a colon, and queries apply them with an equality comparison.
- D. Both a query-driven source and a manual list are supported as the options source, so a small fixed set of regions can simply be typed in.
- E. The role tied to a filter governs who can edit or delete it, not which tile data sources it can be applied to.
Sources9
Practise it for real
Build a descriptive dashboard tile on the sample ORDERS data that one date control drives, and give it a second view.
1.Create a dashboard from Projects » Dashboards, select + and then New Tile from Worksheet, and paste the :daterange/:datebucket query against SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.ORDERS.
Why: The system filters are available to every role, so the tile needs no filter setup.
You should see: The query runs over the default Last day window, bucketed by Day.
2.In the results, select the ORDERS column and open its statistics in the inspector pane.
Why: Numeric columns get a histogram, which shows the spread without another query.
You should see: A histogram of daily order counts that you can drag across to select a range.
3.Select Chart, choose Scorecard or Bar, then select Return to the dashboard.
Why: The tile now summarizes the result visually instead of as raw rows.
You should see: A chart tile at the bottom of the dashboard.
4.From the tile menu, select Duplicate Tile, and give the copy a different chart type.
Why: One query shows one chart type at a time, so a second view needs a second tile.
You should see: Two tiles side by side showing different views of the same data.
5.Change the date range filter to a longer window and select Apply, then switch back to a short window and select Save.
Why: Apply changes only your view. Save sets the default that viewers get.
You should see: Both tiles rerun over each window, and the saved short window is the default.
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“If the number of non-NULL values is an even number, this returns a value equal to the average of the two center values.”
↩︎ Center and spread with SQL aggregates“DISTINCT is not supported for this function.”
↩︎ Center and spread with SQL aggregates - 2.
“STDDEV and STDDEV_SAMP are aliases for the same function.”
↩︎ Center and spread with SQL aggregates“For single-record inputs, STDDEV and STDDEV_SAMP both return NULL.”
↩︎ Exam trap 1“For single-record inputs, STDDEV and STDDEV_SAMP both return NULL.”
↩︎ Prediction - 3.
“you can reference objects in the schema without fully qualifying the object names in your query.”
↩︎ Center and spread with SQL aggregates“you can review generated statistics that display contextual information for any selection”
↩︎ Reading a result with the worksheet inspector“Categorical columns are text columns where the same values are used more than once.”
↩︎ Reading a result with the worksheet inspector“the changes affect all of your results”
↩︎ Reading a result with the worksheet inspector“The statistics are intended to help you make sense of your data at a glance.”
↩︎ Key concept“as the worksheet context, you can reference objects in the schema without fully qualifying the object names in your query.”
↩︎ Checkpoint“Displayed for all categorical columns. Categorical columns are text columns where the same values are used more than once.”
↩︎ Checkpoint - 4.
“Charts use aggregation functions to determine a single value from multiple data points in a bucket.”
↩︎ Reading a result with the worksheet inspector“Each query supports one type of chart at a time.”
↩︎ Reading a result with the worksheet inspector - 5.
“an interactive, cell-based programming environment for Python, SQL, and Markdown”
↩︎ Exploratory analysis in Snowflake Notebooks“Notebooks in Workspaces is the next generation of Snowflake Notebooks”
↩︎ Exploratory analysis in Snowflake Notebooks - 6.
“The cell name of the reference is case-sensitive and must exactly match the name of the referenced cell.”
↩︎ Exploratory analysis in Snowflake Notebooks“However, the entire DataFrame is still available in the notebook session for use.”
↩︎ Exploratory analysis in Snowflake Notebooks“In SQL code, you can only reference Python variables of type string.”
↩︎ Exam trap 2 - 7.
“Altair is imported by default on Snowflake Notebooks as part of Streamlit.”
↩︎ Exploratory analysis in Snowflake Notebooks - 8.
“Dashboards are flexible collections of charts arranged as tiles.”
↩︎ Summary tiles that describe a dataset at a glance“A new tile is added at the bottom of the dashboard with a chart view of the table.”
↩︎ Summary tiles that describe a dataset at a glance“To view shared dashboards, the Snowflake user must use the same role as the session context for the queries that drive the dashboard.”
↩︎ Summary tiles that describe a dataset at a glance“Deleting a tile from a dashboard also deletes the underlying queries.”
↩︎ Exam trap 3“select Unplace Tile. The tile is removed from the dashboard, but remains available to add to the dashboard from the Add tile menu.”
↩︎ Checkpoint - 9.
“Filters are implemented as special keywords that resolve as a subquery or list of values”
↩︎ One date control for every tile“You can only use an equals sign as the comparator for a filter, and as such, cannot use a filter with LIKE or CONTAINS.”
↩︎ One date control for every tile“You cannot use a filter in a stored procedure or a user-defined function (UDF).”
↩︎ One date control for every tile“These filters cannot be edited or dropped.”
↩︎ One date control for every tile“The date range filter always uses the UTC time zone and is not affected by the TIMESTAMP_INPUT_FORMAT parameter.”
↩︎ One date control for every tile“then select Save to save that default filter value for dashboard users.”
↩︎ One date control for every tile“Custom filters let you change the results of a query without directly editing the query.”
↩︎ A reusable filter for comparing segments“Use the format :<string>, without spaces.”
↩︎ A reusable filter for comparing segments“The owner role for the filter must have the USAGE privilege on the warehouse you select.”
↩︎ A reusable filter for comparing segments“You cannot run multiple queries to generate the list of filter options”
↩︎ A reusable filter for comparing segments“will run the underlying query according to the configured schedule, even if no user has the filter open”
↩︎ A reusable filter for comparing segments“Anyone in your account can view and use a custom filter after it is created.”
↩︎ Exam trap 4“Must return the columns name and value.”
↩︎ Prediction“select a role to associate with the filter and run the query used to populate filter values”
↩︎ Checkpoint