diff --git a/docs/users-guide/05-visualizing-results.md b/docs/users-guide/05-visualizing-results.md
index 9ee0f76d726fc..e2cee3040dfa0 100644
--- a/docs/users-guide/05-visualizing-results.md
+++ b/docs/users-guide/05-visualizing-results.md
@@ -1,17 +1,17 @@
-## Visualizing results
+# Visualizing results
-While tables are useful for looking up information or finding specific numbers, it's usually easier to see trends and make sense of data overall using charts.
+While tables are useful for looking up information or finding specific numbers, it's usually easier to see trends and make sense of data using charts.
In Metabase, an answer to a question can be visualized in a number of ways:
-- [Number](#numbers)
+- [Numbers](#numbers)
- [Trend](#trends)
- [Progress bar](#progress-bars)
- [Gauge](#gauges)
- [Table](#tables)
- [Line chart](#line-bar-and-area-charts)
- [Bar chart](#line-bar-and-area-charts)
-- [Line + bar chart](#line-plus-bar-charts)
+- [Combo chart](#line-plus-bar-charts)
- [Row chart](#row-charts)
- [Area chart](#line-bar-and-area-charts)
- [Scatterplot or bubble chart](#scatterplots-and-bubble-charts)
@@ -19,27 +19,31 @@ In Metabase, an answer to a question can be visualized in a number of ways:
- [Funnel](#funnel)
- [Map](#maps)
-To change how the answer to your question is displayed, click on the Visualization button in the bottom-right of the screen to open the visualization selection sidebar.
+To change how the answer to your question is displayed, click on the **Visualization** button in the bottom-right of the screen to open the visualization sidebar.
![Visualization options](images/VisualizeChoices.png)
-If a particular visualization doesn’t really make sense for your answer, that option will appear grayed-out in the sidebar. You can still select a grayed-out option, though you might need to open the chart options to make your selection work with your data.
+If a particular visualization doesn’t really make sense for your answer, that option will appear grayed out in the sidebar. You can still select a grayed-out option, though you might need to open the chart options to make your selection work with your data.
-Once a question is answered, you can save or download the answer, or add it to a dashboard or Pulse.
+Once a question returns results, you can save the question, download the results, or add the question to a [dashboard](07-dashboards.md) or [pulse](10-pulses.md).
-### Visualization types and options
+## Visualization types and options
-Each visualization type has its own advanced options you can tweak. Just click the Settings button next to the Visualization button to see all your options. The options panel also automatically opens up whenever you pick a new visualization type. Here's an overview of what you can do:
+Each visualization type has its own advanced options. Click the **Settings** button next to the Visualization button to see your options. The options panel also automatically opens up whenever you pick a new visualization type. Here's an overview of what you can do:
-#### Numbers
+### Numbers
-This option is for displaying a single number, nice and big. The options for numbers include adding character prefixes or suffixes to it (so you can do things like put a currency symbol in front or a percent at the end), setting the number of decimal places you want to include, and multiplying your result by a number (like if you want to multiply a decimal by 100 to make it look like a percent). If you want to _divide_ by a number, then just multiply it by a decimal (e.g, if your result is `100`, but you want it to display as `1`, simply multiply it by 0.01).
+The **Numbers** option is for displaying a single number, nice and big. The options for numbers include:
+
+- **Adding character prefixes or suffixes** to it (so you can do things like put a currency symbol in front or a percent at the end),
+- **Setting the number of decimal places** you want to include, and
+- **Multiplying your result by a number** (like if you want to multiply a decimal by 100 to make it look like a percent). If you want to _divide_ by a number, then just multiply it by a decimal (e.g, if your result is `100`, but you want it to display as `1`, simply multiply it by 0.01).
![Number](images/visualizations/number.png)
-#### Trends
+### Trends
-The Trend visualization is great for displaying how a single number has changed over time. To use this visualization, you'll need to have a single number grouped by a Time field, like the Count of Orders by Created At. The Trend will show you the value of the number during the most recent period, and below that you'll see how much the number has increased or decreased compared to its value in the period before that. The period is determined by your group-by field: if you're grouping by Day, the Trend will show you the most recent day compared to the day before that.
+The **Trend** visualization is great for displaying how a single number has changed over time. To use this visualization, you'll need to have a single number grouped by a Time field, like the Count of Orders by Created At. The Trend will show you the value of the number during the most recent period, as well as how much the number has increased or decreased compared to its value in the previous period. The period is determined by your group-by field; if you're grouping by Day, the Trend will show you the most recent day compared to the day before that.
![Trend](images/visualizations/trend.png)
@@ -47,15 +51,15 @@ By default, Trends will display increases as green (i.e. "good") and decreases a
![Trend settings](images/visualizations/trend-settings.png)
-#### Progress bars
+### Progress bars
-Progress bars are for comparing a single number to a goal value that you set. Open up the settings for your progress bar to choose a value for your goal, and Metabase will show you how far away your question's current result is from the goal.
+**Progress bars** are for comparing a single number to a goal value that you set. Open up the settings for your progress bar to choose a value for your goal, and Metabase will show you how far away your question's current result is from the goal.
![Progress bar](images/visualizations/progress.png)
-#### Gauges
+### Gauges
-Ah, gauges: you either love 'em or you hate 'em. …Or you feel "meh" about them, I guess. Whatever the case, gauges allow you to show a single number and where its value falls within a set of colored ranges that you can specify. By default, when you choose the Gauge visualization, Metabase will create red, yellow, and green ranges for you.
+Ah, **gauges**: you either love 'em or you hate 'em. …Or you feel "meh" about them, I guess. Whatever the case, gauges allow you to show a single number in the context of a set of colored ranges that you can specify. By default, when you choose the Gauge visualization, Metabase will create red, yellow, and green ranges for you.
![Gauge](images/visualizations/gauge.png)
@@ -63,51 +67,51 @@ Open up the visualization settings to define your own ranges, choose colors for
![Gauge settings](images/visualizations/gauge-settings.png)
-#### Tables
+### Tables
-The Table option is good for looking at tabular data (duh), or for lists of things like users or orders. The visualization options for tables allow you to add, hide, or rearrange fields in the table you're looking at, as well as modify their formatting.
+The **Table** option is good for looking at tabular data (duh), or for lists of things like users or orders. The visualization options for tables allow you to add, hide, or rearrange fields in the table you're looking at, as well as modify their formatting.
-##### Rearranging, adding, and removing columns
+#### Rearranging, adding, and removing columns
![Additional fields](images/visualizations/add-fields.png)
Open up the settings for your table and you'll see the Columns tab, which displays all the columns currently being shown in the table. Below that you'll see a list of more columns from linked tables, if any, that you can add to the current table view.
-To hide a column, click the X icon on it; that'll send it down to the "More columns" area in case you want to bring it back. To add a linked column, just click the + icon on it, which will bring it to the "Visible columns" section. Click and drag any of the columns listed there to rearrange the order in which they appear. Another super easy way to rearrange columns without having to open up the visualization settings is to simply click and drag on a column's heading to move it where you'd like it to go.
+To hide a column, click the X icon on it; that'll send it down to the **More columns** area in case you want to bring it back. To add a linked column, just click the + icon on it, which will bring it to the **Visible columns** section. Click and drag any of the columns listed there to rearrange the order in which they appear. Another super easy way to rearrange columns without having to open up the visualization settings is to simply click and drag on a column's heading to move it where you'd like it to go.
-**Note:** changing these options doesn't change the actual table itself; it just creates a custom view of it that you can save as a "question" in Metabase and refer back to later, share with others, or add to a dashboard.
+> Changing these options doesn't change the actual table itself; these changes create a custom view of the table that you can save as a **question** in Metabase and refer back to later, share with others, or add to a [dashboard](08-dashboards.md).
-##### Column formatting options
+#### Column formatting options
To format the display of any column in a table, click on the column heading and choose the `Formatting` option (you can also get there by clicking on the gear on any column when in the `Columns` tab of the visualization settings).
![Column formatting](images/visualizations/column-header-formatting.png)
-The options you see will be different depending on the type of column you're viewing:
+The options you see will differ depending on the type of column you're viewing:
**Dates**
-- `Date style` gives you a bunch of different choices for how to display the date.
-- `Abbreviate names of days and months`, when turned on, will turn things like `January` to `Jan`, and `Monday` to `Mon`.
-- `Show the time` lets you decide whether or not to display the time, and if so, how. You can include hours and minutes, and additionally seconds and milliseconds.
+- **Date style** gives you a bunch of different choices for how to display the date.
+- **Abbreviate names of days and months**, when turned on, will turn things like `January` to `Jan`, and `Monday` to `Mon`.
+- **Show the time** lets you decide whether or not to display the time, and if so, how. You can include hours and minutes, and additionally seconds and milliseconds.
**Numbers**
-- `Show a mini bar chart` will display a small horizontal bar next to each number in this column to show its size relative to the other values in the column.
-- `Style` lets you choose to display the number as a plain number, a percent, in scientific notation, or as a currency.
-- `Separator style` gives you various options for how commas and periods are used to separate the number.
-- `Minimum number of decimal places` forces the number to be displayed with exactly this many decimal places.
-- `Multiply by a number` multiplies each number in this column by whatever you type here. Just don't type an emoji here; it almost always causes a temporal vortex to manifest.
-- `Add a prefix/suffix` lets you put a symbol, word, or whatever before or after each cell's value.
+- **Show a mini bar chart** will display a small horizontal bar next to each number in this column to show its size relative to the other values in the column.
+- **Style** lets you choose to display the number as a plain number, a percent, in scientific notation, or as a currency.
+- **Separator style** gives you various options for how commas and periods are used to separate the number.
+- **Minimum number of decimal places** forces the number to be displayed with exactly this many decimal places.
+- **Multiply by a number** multiplies each number in this column by whatever you type here. Just don't type an emoji here; it almost always causes a temporal vortex to manifest.
+- **Add a prefix/suffix** lets you put a symbol, word, or whatever before or after each cell's value.
**Currency**
Currency columns have all the same options as numbers, plus the following:
-- `Unit of Currency` lets you change the unit of currency from whatever the system default is.
-- `Currency label style` allows you to switch between displaying the currency label as a symbol, a code like (USD), or the full name of the currency.
-- `Where to display the unit of currency` lets you toggle between showing the currency label in the column heading or in every cell in the column.
+- **Unit of Currency** lets you change the unit of currency from whatever the system default is.
+- **Currency label style** allows you to switch between displaying the currency label as a symbol, a code like (USD), or the full name of the currency.
+- **Where to display the unit of currency** lets you toggle between showing the currency label in the column heading or in every cell in the column.
-##### Formatting data in charts
+#### Formatting data in charts
While we're talking about formatting, we thought you should also know that you can access formatting options for the columns used in a chart. Just open the visualization settings and select the `Data` tab:
@@ -117,65 +121,66 @@ Then click on the gear icon next to the column that you want to format. Dates, n
![Chart formatting options](images/visualizations/chart-formatting-options.png)
-##### Conditional table formatting
+#### Conditional table formatting
-Sometimes is helpful to highlight certain rows or columns in your tables when they meet a specific condition. You can set up conditional formatting rules by going to the visualization settings while looking at any table, then clicking on the `Formatting` tab.
+Sometimes is helpful to highlight certain rows or columns in your tables when they meet a specific condition. You can set up conditional formatting rules by going to the visualization settings while looking at any table, then clicking on the **Conditional Formatting** tab.
![Conditional formatting](images/visualizations/conditional-formatting.png)
When you add a new rule, you'll first need to pick which column(s) should be affected. Your columns can be formatted in one of two ways:
-1. **Single color:** pick this if you want to highlight cells in the column if they're greater, less than, or equal to a specific number, or if they match or contain a certain word or phrase. You can optionally highlight the whole row of a cell that matches the condition you pick so that it's easier to spot as you scroll down your table.
-2. **Color range:** choose this option if you want to tint all the cells in the column from smallest to largest or vice a versa. This option is only available for numeric columns.
+- **Single color**. Pick single color if you want to highlight cells in the column if they're greater, less than, or equal to a specific number, or if they match or contain a certain word or phrase. You can optionally highlight the whole row of a cell that matches the condition you pick so that it's easier to spot as you scroll down your table.
+- **Color range**. Choose color range if you want to tint all the cells in the column from smallest to largest or vice a versa. This option is only available for numeric columns.
You can set as many rules on a table as you want. If two or more rules disagree with each other, the rule that's on the top of your list of rules will win. You can click and drag your rules to reorder them, and click on a rule to edit it.
-##### Pivoted tables
+#### Pivoted tables
-If your table is a result that contains one numeric column and two grouping columns, Metabase will also automatically "pivot" your table, like in the example below. What this does is it takes one of your columns and rotates it 90 degrees ("pivots" it) so that each of its values becomes a column heading. If you open up the visualization settings by clicking the gear icon, you can choose which column to pivot in case Metabase got it wrong; or you can also turn the pivoting behavior off entirely.
+If your table is a result that contains one numeric column and two grouping columns, Metabase will also automatically "pivot" your table, like in the example below. Pivoting takes one of your columns and rotates it 90 degrees ("pivots" it) so that each of its values becomes a column heading. If you open up the visualization settings by clicking the gear icon, you can choose which column to pivot in case Metabase got it wrong; or you can also turn the pivoting behavior off entirely.
![Pivot table](images/visualizations/pivot.png)
-#### Line, bar, and area charts
+### Line, bar, and area charts
-Line charts are best for displaying the trend of a number over time, especially when you have lots of x-axis values. Bar charts are great for displaying a number grouped by a category (e.g., the number of users you have by country), and they can also be useful for showing a number over time if you have a smaller number of x-axis values (like orders per month this year).
+**Line charts** are best for displaying the trend of a number over time, especially when you have lots of x-axis values. Bar charts are great for displaying a number grouped by a category (e.g., the number of users you have by country). Bar charts can also be useful for showing a number over time if you have a smaller number of x-axis values (like orders per month this year).
![Bar chart](images/visualizations/bar.png)
-Area charts are useful when comparing the proportions of two metrics over time. Both bar and area charts can be stacked.
+**Area charts** are useful when comparing the proportions of two metrics over time. Both bar and area charts can be stacked.
![Stacked area chart](images/visualizations/area.png)
**Trend lines**
-Another useful option for line, area, bar, and scatter charts is trend lines. If you have a question where you're grouping by a time field, open up the visualization settings and turn the `Show trend line` toggle on to display a trend line. Metabase will choose the best type of line to fit to the trend of your series. This will even work if you have multiple metrics selected in your summary. But it won't work if you have any groupings beyond the one time field.
+
+**Trend lines** are another useful option for line, area, bar, and scatter charts. If you have a question where you're grouping by a time field, open up the visualization settings and turn the `Show trend line` toggle on to display a trend line. Metabase will choose the best type of line to fit to the trend of your series. Trend lines will even work if you have multiple metrics selected in your summary. But trend lines won't work if you have any groupings beyond the one time field.
![Trend lines](images/visualizations/trend-lines.png)
-#### Line + Bar charts
+### Combo charts
-Also called Combo Charts, the Line + Bar chart lets you combine bars and lines (or areas) on the same chart.
+Combo charts let you combine bars and lines (or areas) on the same chart.
![Line + bar](images/visualizations/combo-chart.png)
-Metabase will pick one of your series to display as a line, and another to display as a bar by default. Open up the visualization settings to change which series are lines, bars, or areas, and to change other per-series settings like colors. Click the down arrow icon on the right of a series to see additional options:
+Metabase will pick one of your series to display as a line, and another to display as a bar by default. Open up the visualization settings to change which series are lines, bars, or areas, as well as to change per-series settings like colors. Click the down arrow icon on the right of a series to see additional options:
![Line + bar](images/visualizations/combo-chart-settings.png)
-To use a Line + Bar chart, you'll either need to have two or more metrics selected in the Summarize By section of your question, with one or two grouping columns, like this…
+To use a Combo chart you'll either need to have two or more metrics selected in the Summarize By section of your question, with one or two grouping columns, like this:
![Data for Line + Bar chart](images/visualizations/combo-chart-data-1.png)
-…or you'll need a question with a single metric and with two grouping columns, like this:
+Or you'll need a question with a single metric and two grouping columns, like this:
![Data for Line + Bar chart](images/visualizations/combo-chart-data-2.png)
-#### Row charts
+### Row charts
-If you're trying to group a number by a column that has a lot of possible values, like a Vendor or Product Title field, try visualizing it as a row chart. Metabase will show you the bars in descending order of size, with a final bar at the bottom for items that didn't fit.
+If you're trying to group a number by a column that has a lot of possible values, like a Vendor or Product Title field, try visualizing it as a **row chart**. Metabase will show you the bars in descending order of size, with a final bar at the bottom for items that didn't fit.
![Row chart](images/visualizations/row.png)
-##### Histograms
+#### Histograms
If you have a bar chart like Count of Users by Age, where the x-axis is a number, you'll get a special kind of chart called a **histogram**, where each bar represents a range of values (called a "bin"). Note that Metabase will automatically bin your results any time you use a number as a grouping, even if you aren't viewing a bar chart. Questions that use latitude and longitude will also get binned automatically.
@@ -185,7 +190,7 @@ By default, Metabase will automatically choose a good way to bin your results. B
![Binning options](images/notebook/histogram-bins.png)
-##### Options for line, bar, and area charts
+#### Options for line, bar, and area charts
These three charting types have very similar options, which are broken up into the following:
@@ -195,69 +200,69 @@ Here's where you can choose the columns you want to plot on your x and y axes. T
**Display**
-There's quite a bit you can do in this tab:
+There's quite a bit you can do in this tab, but the options available will depend on the data in your chart.
-- Set the colors and labels for the series on your chart.
-- Change the style of your lines for Line and Area charts, and choose whether or not to display dots on them.
-- Use the "Replace missing values with…" setting to change how your chart deals with missing values. You can use linear interpolation, or display those points as zero or as nothing.
-- Add a goal line. This can be used in conjunction with [alerts](15-alerts.md) to send an email or a Slack message when your metric cross this line.
-- If you're looking at a time series chart, you can turn on a trend line to show where things are heading.
-- Show values on data points. The default setting will try and fit as many values on your chart as will fit nicely, but you can also force Metabase to show the values for each and every data point, which it will do begrudgingly.
+- **Set the colors and labels** for the series on your chart.
+- **Change the style of your lines** for Line and Area charts, and choose whether to display dots on the lines.
+- **Specify how to handle missing values**. Use the "Replace missing values with…" setting to change how your chart deals with missing values. You can use linear interpolation, or display those points as zero or as nothing.
+- **Add a goal line**. Goal lines can be used in conjunction with [alerts](15-alerts.md) to send an email or a Slack message when your metric cross this line.
+- **Add a trend line**. If you're looking at a time series chart, you can turn on a trend line to show where things are heading.
+- **Show values on data points**. The default setting will try and fit as many values on your chart as will fit nicely, but you can also force Metabase to show the values for each and every data point, which it will do begrudgingly. Showing values also works with multi-series charts, but be aware that the more data points you add, the more crowded with values the charts will become.
**Axes**
-There are three main things you can do here:
+There are three main ways to configure axes:
-- Change the scale for your axes. If you're looking at a time series chart, your x-axis can use a time series scale or an ordinal one. When using "Timeseries", it will always be displayed in ascending order, so oldest to newest, while "Ordinal" will display in the order the data is returned. Your y-axis can use a linear, power, or logarithmic scale.
-- Hide or show the tick marks on your axes. You can also choose to rotate the tick marks on the x-axis to help them fit better.
-- Edit the range of your y-axis. Metabase sets an automatic range by default, but you can toggle that off and input a custom minimum and maximum value for the y-axis if you'd like.
+- **Change the scale for your axes**. If you're looking at a time series chart, your x-axis can use a time series scale or an ordinal one. When using "Timeseries", it will always be displayed in ascending order, so oldest to newest, while "Ordinal" will display in the order the data is returned. Your y-axis can use a linear, power, or logarithmic scale.
+- **Hide or show the tick marks on your axes**. You can also choose to rotate the tick marks on the x-axis to help them fit better.
+- **Edit the range of your y-axis**. Metabase sets an automatic range by default, but you can toggle that off and input a custom minimum and maximum value for the y-axis if you'd like.
**Labels**
-Here's where you can choose to hide the label for your x- or y-axis. You can also customize the text for your axis labels here.
+Here's where you can choose to hide the **label** for your x- or y-axis. You can also customize the text for your axes labels here.
-#### Scatterplots and bubble charts
+### Scatterplots and bubble charts
-Scatterplots are useful for visualizing the correlation between two variables, like comparing the age of your users vs. how many dollars they've spent on your products. To use a scatterplot, you'll need to ask a question that results in two numeric columns, like `Count of Orders grouped by Customer Age`. Alternatively, you can use a raw data table and select the two numeric fields you want to use in the chart options.
+**Scatterplots** are useful for visualizing the correlation between two variables, like comparing the age of your users vs. how many dollars they've spent on your products. To use a scatterplot, you'll need to ask a question that results in two numeric columns, like `Count of Orders grouped by Customer Age`. Alternatively, you can use a raw data table and select the two numeric fields you want to use in the chart options.
-If you have a third numeric field, you can also create a bubble chart. Select the Scatter visualization, then open up the chart settings and select a field in the `bubble size` dropdown. This field will be used to determine the size of each bubble on your chart. For example, you could use a field that contains the total dollar amount for each x-y pair — i.e., larger bubbles for larger total dollar amounts spent on orders.
+If you have a third numeric field, you can also create a **bubble chart**. Select the Scatter visualization, then open up the chart settings and select a field in the **bubble size** dropdown. This field will be used to determine the size of each bubble on your chart. For example, you could use a field that contains the total dollar amount for each x-y pair — i.e. larger bubbles for larger total dollar amounts spent on orders.
Scatterplots and bubble charts also have similar chart options as line, bar, and area charts, including the option to display trend or goal lines.
![Scatter](images/visualizations/scatter.png)
-#### Pie or donut charts
+### Pie or donut charts
-A pie or donut chart can be used when breaking out a metric by a single dimension, especially when the number of possible breakouts is small, like users by gender. If you have more than a few breakouts, like users per country, it's usually better to use a bar chart so that your users can more easily compare the relative sizes of each bar.
+A **pie or donut chart** can be used when breaking out a metric by a single dimension, especially when the number of possible breakouts is small, like users by gender. If you have more than a few breakouts, like users per country, it's usually better to use a bar chart so that your users can more easily compare the relative sizes of each bar.
-The options for pie charts let you choose which field to use as your measurement, and which one to use for the dimension (i.e., the pie slices). You can also customize the color of each piece slice, the pie chart's legend, whether or not to show each slice's percent of the whole in the legend, and the minimum size a slice needs to be in order for it to be displayed.
+The options for pie charts let you choose which field to use as your measurement, and which one to use for the dimension (i.e. the pie slices). You can also customize the color of each slice, the pie chart's legend, whether or not to show each slice's percent of the whole in the legend, and the minimum size a slice needs to be in order for Metabase to display it.
![Donut](images/visualizations/donut.png)
-#### Funnel
+### Funnel
-Funnels are commonly used in e-commerce or sales to visualize how many customers are present within each step of a checkout flow or sales cycle. At their most general, funnels show you values broken out by steps, and the percent decrease between each successive step. To create a funnel in Metabase, you'll need to have a table with at least two columns: one column that contains the metric you're interested in, and another that contains the funnel's steps.
+**Funnels** are commonly used in e-commerce or sales to visualize how many customers are present within each step of a checkout flow or sales cycle. At their most general, funnels show you values broken out by steps, and the percent decrease between each successive step. To create a funnel in Metabase, you'll need to have a table with at least two columns: one column that contains the metric you're interested in, and another that contains the funnel's steps.
For example, I might have an Opportunities table, and I could create a question that gives me the number of sales leads broken out by a field that contains stages such as `Prospecting`, `Qualification`, `Proposal`, `Negotiation`, and `Closed`. In this example, the percentages shown along the x-axis tell you what percent of the total starting opportunities are still present at each subsequent step; so 18.89% of our total opportunities have made it all the way to being closed deals. The number below each percent is the actual value of the count at that step — in our example, the actual number of opportunities that are currently at each step. Together, these numbers help you figure out where you're losing your customers or users.
![Funnel](images/visualizations/funnel.png)
-#### Maps
+### Maps
-When you select the Map visualization setting, Metabase will automatically try and pick the best kind of map to use based on the table or result set you're currently looking at. Here are the maps that Metabase uses:
+When you select the **Map** visualization setting, Metabase will automatically try and pick the best kind of map to use based on the table or result set. Here are the maps that Metabase uses:
-- **United States Map** — Creating a map of the United States from your data requires your results to contain a column that contains names of states or two-letter state codes. This lets you do things like visualize the count of your users broken out by state, with darker states representing more users.
-- **World Map** — To visualize your results in the format of a map of the world broken out by country, your result must contain a column with two-letter country codes. (E.g., count of users by country.)
+- **United States Map**. Creating a map of the United States from your data requires your results to contain a column that contains names of states or two-letter state codes. This lets you do things like visualize the count of your users broken out by state, with darker states representing more users.
+- **World Map**. To visualize your results in the format of a map of the world broken out by country, your result must contain a column with two-letter country codes. (E.g., count of users by country.)
![Region map](images/visualizations/map.png)
-- **Pin Map** — If your table contains a latitude and longitude field, Metabase will try to display it as a pin map of the world. This will put one pin on the map for each row in your table, based on the latitude and longitude fields. You can try this with the Sample Dataset that's included in Metabase: start a new question and select the People table, use `raw data` for your view, and choose the Map option for your visualization. you'll see a map of the world, with each dot representing the latitude and longitude coordinates of a single person from the People table.
+- **Pin Map**. If your results contains a latitude and longitude field, Metabase will try to display the results as a pin map of the world. Metabase will put one pin on the map for each row in your table, based on the latitude and longitude fields. You can try this with the Sample Dataset that's included in Metabase: start a new question and select the People table, use `raw data` for your view, and choose the Map option for your visualization. You'll see a map of the world, with each dot representing the latitude and longitude coordinates of a single person from the People table.
![Pin map](images/visualizations/pin-map.png)
-When you open up the Map options, you can manually switch between a region map (i.e., United States or world) and a pin map. If you're using a region map, you can also choose which field to use as the measurement, and which to use as the region (i.e. State or Country).
+When you open up the Map options, you can manually switch between a region map (e.g., United States) and a pin map. If you're using a region map, you can also choose which field to use as the measurement, and which field to use as the region (e.g., State or Country).
-Metabase also allows administrators to add custom region maps via GeoJSON files through the Metabase Admin Panel.
+Metabase also allows administrators to add custom region maps via GeoJSON files through the Metabase **Admin Panel**.
---
diff --git a/docs/users-guide/09-multi-series-charting.md b/docs/users-guide/09-multi-series-charting.md
index 785a52f5171ac..e42a444e3d1d9 100644
--- a/docs/users-guide/09-multi-series-charting.md
+++ b/docs/users-guide/09-multi-series-charting.md
@@ -7,73 +7,88 @@ Data in isolation is rarely all that useful. One of the best ways to add context
- New users per day vs. returning users per day.
- Orders per day from a few different product lines.
-### In Metabase there are two main ways to get data side-by-side.
+### Displaying data side by side
-1. Combining two existing saved questions that share a common dimension (like time) on a dashboard
+There are two main ways to visualize data side by side:
-e.g. Let me see revenue over time and cost over time together.
+1. [**Ask a question that involves multiple dimensions**](#ask-a-question-that-involves-multiple-dimensions) with the Simple or Custom query builders (or in SQL, if you’re fancy). Example: the count of users by region over time.
-2. Asking a question that involves multiple dimensions in the query builder (or in SQL if you’re fancy).
+2. [**Combine two saved questions**](#combining-two-saved-questions) that share a common dimension (like time) on a dashboard. For example, you could look at revenue over time and costs over time together.
-e.g. The count of users by region over time.
+### Ask a question that involves multiple dimensions
-### Combining two existing saved questions
+If you’re creating a new question, you can view the results as a multi-series visualization by summarizing your data and grouping it into two groups.
-If you already have two or more saved questions you’d like to compare, and they share a dimension, they can be combined on any dashboard. Here’s how:
+As an example, we might want to see which website or service is referring the most people to our website. In the **Sample Dataset** that ships with Metabase, you would group by the `Source` and `Created At` columns of the **People** table.
+
+To create the multi-series chart, select the **People** table, click on the **Summarize** button in the upper right, then add `Source` and `Created At` as groupings (the `count of rows` metric that we want is selected by default). Be sure to click the plus button to the right of your selection, so Metabase knows to add the grouping; otherwise, Metabase will switch to that grouping. [Learn more about asking questions](04-asking-questions.md).
+
+Metabase will automatically display a multi-series line chart visualization of how each referrer has performed for us.
+
+![multi-series in the query builder](images/multi-series-charts/multi-series_query_builder.png)
+
+You can also create a multi-series chart by composing a custom question in the notebook editor. All you need to do is summarize your data (e.g., count the rows) and group that data into multiple groups (e.g. `Created At` by month and Product Category).
-1. Add a question with a dimension like time or a category to a dashboard. In practice, these will usually be line charts or bar charts.
+![Composing a multi-series question in the notebook editor](images/multi-series-charts/notebook_editor_multi-series.png)
-2. While in edit mode on the dashboard, hovering on the card will show a “Edit data” button. Click this button to start adding series that you want to compare to the first series..
+Note: you won’t be able to add another saved question to multi-series visualizations made in this fashion. Metabase can visualize up to 100 distinct values of a dimension at once, so if you're selecting a field that contains a lot of values, you might need to filter the values.
-![multiseriestrigger](images/MultiSeriesTrigger.png)
-3. In the Edit Data modal you’ll see the original question, and on the right you’ll see a list of compatible questions you can choose from. Check the box next to any questions you’d like to see side-by-side with the original, and Metabase will add it to the same chart.
+### Combining two saved questions
-![multiseriesmodal1](images/MultiSeriesModal1.png)
+If you already have two or more saved questions you’d like to compare, and they share a dimension, they can be combined on any dashboard. Here’s how:
+
+1. Add a question with a dimension like time or category to a dashboard. In practice, these will usually be line charts or bar charts.
+
+2. While in edit mode on the dashboard, hovering over a card will display some editing options in the upper right of the question, including an option to **add a line**, as well as a **gear** icon. Click on the add a line option (the **+** with a line and the word "Add" next to it).
-The X and Y axis will automatically update if necessary and Metabase will create a legend using the existing card titles to help you understand which question maps to which series on the chart. Repeat this process as many times as you need.
+![add multi-series](images/multi-series-charts/add_series.png)
-To remove a series either uncheck the box, or click the x next to the title in the legend above the chart.
+3. In the Edit Data modal, you’ll see the original question on the left, with a list of compatible questions you can choose from on the right. Search question(s) to add, and check the box next to each question you’d like to see alongside with the original. Metabase will add the question(s) to the same chart.
-![multiseriesmodal2](images/MultiSeriesModal2.png)
+![multi-series edit modal](images/multi-series-charts/edit_modal.png)
-Once you have your chart looking how you’d like, hit done and your changes will be shown on the card in the dashboard. Depending on how dense your data is, at this point you might want to consider enlarging your chart to make sure the data is legible.
+If necessary, the X and Y axes will automatically update. Metabase will create a legend using the existing card titles to help you understand which question maps to which series on the chart. Repeat this process as many times as you need.
-![multiseriefinished](images/MultiSeriesFinished.png)
+![Edit modal with multi-series](images/multi-series-charts/edit_modal_multi-series.png)
-#### A quick note about SQL based questions.
+To remove a series, simply uncheck its box.
-Metabase has less information about SQL based questions, so we cannot guarantee if they can be added reliably. You'll see a little warning sign next to SQL questions to indicate this and when you try adding them just be aware it may not work.
+Once you have your chart looking how you’d like, hit done. Metabase will show your changes on the card in the dashboard. Depending on how dense your data is, at this point you might want to consider enlarging your chart to make sure the data is legible.
+
+> **SQL questions may not work**. Metabase has less information about SQL-based questions, so we cannot guarantee they can be added reliably. You'll see a little warning sign next to SQL questions to indicate this uncertainty, so be aware that adding these kinds of questions may not work.
### Combining Number charts
-If you need to compare single numbers and get a sense of how they differ, Metabase also lets you turn multiple Number charts into a bar chart. To do this, follow the same process outlined above. While editing a dashboard, click “edit data” on the Number chart of your choice and then select the other saved question(s) you’d like to see represented on the bar chart. (At Metabase, we use this to create simple funnel visualizations.)
+If you need to compare single numbers to get a sense of how they differ, Metabase can turn multiple number charts into a bar chart.
-### Creating a multi-series visualization in the query builder.
+As above, while editing a dashboard, hover over a number chart of your choice, and click on the icon with the **+** and bar chart icon to add a saved question.
-If you’re creating a new question you can also view the result as a multi-series visualization. To do this you’ll need to summarize and add two groupings to your question.
+![Add bar chart](images/multi-series-charts/add_bar_chart.png)
-As an example, we might want to see which website or service is referring the most people to our website. (In the sample dataset that ships with Metabase this would involve using the `Source` and `Created At` columns of the `People` table.)
+Use the search bar to find other saved question(s) that you’d like to see represented on the bar chart, and click the checkbox to add them to your chart. In this case, we added **Widget orders** to compare them to **Gadget orders**.
-To do this we’d click the Summarize button, and then add `Source` and `Created At` as groupings (the `count of rows` metric that we want is already selected by default). [Learn more about asking questions](04-asking-questions.md).
+![From numbers to bar chart](images/multi-series-charts/numbers_to_bar_chart.png)
-Metabase will automatically display a multi-series line chart visualization of how each referrer has performed for us.
+### Multi-series charts, values, and legibility
+
+When displaying multiple series, it’s important to keep legibility in mind. Combining many series can sometimes decrease the communication value of the data.
-![multiseriesquerybuilder](images/MultiSeriesQueryBuilder.png)
+Metabase allows you to add values to multi-series charts, but go easy on this feature, especially on charts with lots of data points. Adding values to multiple series, each with many data points, can make charts more difficult to read.
-It’s worth noting that at this time you won’t be able to add another saved question to multi-series visualizations made in this fashion. Metabase can only visualize up to 20 values of a dimension at once, so you may need to filter the values if you're selecting a field that contains a lot of values like "State."
+From the **Visualization -> Display** options, you can toggle the option: **Show values on data points**. Metabase will do its best to fit as many values as can fit nicely. You can also force Metabase to (begrudgingly) show values for all data points, by setting the **Values to show** to **All**.
-### Other multiple series tips
+![add values to multi-series chart](images/multi-series-charts/add_values.gif)
-- When displaying multiple series it’s important to keep legibility in mind. Combining many series can sometimes decrease the communication value of the data.
+You can also toggle values for each individual series. If you have three series, for example, you can show values on one, two, or all three series. In the **Display** tab, click on the down arrow to the right of a series to expand its details, and toggle **Show values for this series** to show or hide its values. You can also toggle values for the whole chart, then selectively hide values for individual series until you have your chart looking just right.
-### To recap:
+Additionally, there is an option to configure the formatting of the values:
-- Existing saved questions can be combined and displayed on dashboards when editing the dashboard.
-- Scalars can be combined to create bar charts and simple funnels
-- You can produce a multi-series visualization in the query builder by adding two dimensions to your query.
+- **Auto**. Metabase selects the appropriate style for you
+- **Compact**. Metabase abbreviates values, e.g., 1,000 becomes 1K.
+- **Full**. Values are displayed in their natural beauty.
-Go forth and start letting your data get to know each other.
+Now go forth and start letting your data get to know each other.
---
diff --git a/docs/users-guide/custom-questions.md b/docs/users-guide/custom-questions.md
index fad2ddfb7719a..f07f47011718c 100644
--- a/docs/users-guide/custom-questions.md
+++ b/docs/users-guide/custom-questions.md
@@ -86,12 +86,14 @@ After you click on the Join Data button to add a join step, you'll need to pick
Next, you'll need to pick the columns you want to join on. This means you pick a column from the first table, and a column from the second table, and the join will stitch rows together where the value from the first column is equal to the value in the second column. A very common example is to join on an ID column in each table, so if you happened to pick a table to join on where there is a foreign key relationship between the tables, Metabase will automatically pick those corresponding ID columns for you. At the end of your join step, there's a `Columns` button you can click to choose which columns you want to include from the joined data.
-By default, Metabase will do a left outer join, but you can click on the Venn diagram icon to change this to a different type of join. The options you'll see will differ based on the type of database you're using. Here are what the basic types of joins each do:
+By default, Metabase will do a left outer join, but you can click on the Venn diagram icon to select a different type of join. Not all databases support all types of joins, so Metabase will only display the options supported by the database you're using.
+
+Here are the basic types of joins:
- **Left outer join:** select all records from Table A, along with records from Table B that meet the join condition, if any.
-- **Right outer join:** select all records from Table B, along with records from Table B that meet the join condition, if any.
+- **Right outer join:** select all records from Table B, along with records from Table A that meet the join condition, if any.
- **Inner join:** only select the records from Table A and B where the join condition is met.
-- **Full outer join:** select all records from both tables, whether or not the join condition is met. This is not available for MySQL or H2, and is only available for some database types, like Spark SQL, SQL Server, and SQLite.
+- **Full outer join:** select all records from both tables, whether or not the join condition is met.
**A left outer join example:** If Table A is Orders and Table B is Customers, and assuming you do a join where the `customer_id` column in Orders is equal to the `ID` column in Customers, when you do a left outer join your results will be a full list of all your orders, and each order row will also display the columns of the customer who placed that order. Since a single customer can place many orders, a given customer's information might be repeated many times for different order rows. If there isn't a corresponding customer for a given order, the order's information will be shown, but the customer columns will just be blank for that row.
diff --git a/docs/users-guide/expressions.md b/docs/users-guide/expressions.md
index 5db02368f94f4..7f8e0fe10fe7b 100644
--- a/docs/users-guide/expressions.md
+++ b/docs/users-guide/expressions.md
@@ -94,21 +94,18 @@ This would return rows where `Created At` is between January 1, 2020 and March 3
Certain database types don't support some of the above functions:
-MySQL and SQL Server
+**BigQuery**: `abs`, `ceil`, `floor`, `median`, `percentile` and `round`
-- median
-- percentile
+**H2**: `median`, `percentile` and `regexextract`
-SQLite
+**MySQL**: `median`, `percentile` and `regexextract`
-- log
-- median
-- percentile
-- power
-- standardDeviation
-- sqrt
-- variance
+**SQL Server**: `median`, `percentile` and `regexextract`
-Additionally, **Vertica**, **BigQuery**, and **Presto** only provide _approximate_ results for median and percentile.
+**SQLite**: `log`, `median`, `percentile`, `power`, `regexextract`, `standardDeviation`, `sqrt` and `variance`
+
+**Vertica**: `median` and `percentile`
+
+Additionally, **Presto** only provides _approximate_ results for `median` and `percentile`.
If you're using or maintaining a third-party database driver, please [refer to the wiki](https://github.com/metabase/metabase/wiki/What's-new-in-0.35.0-for-Metabase-driver-authors) to see how your driver might be impacted.
diff --git a/docs/users-guide/images/MultiSeriesFinished.png b/docs/users-guide/images/MultiSeriesFinished.png
deleted file mode 100644
index 6c3fa315523e9..0000000000000
Binary files a/docs/users-guide/images/MultiSeriesFinished.png and /dev/null differ
diff --git a/docs/users-guide/images/MultiSeriesModal1.png b/docs/users-guide/images/MultiSeriesModal1.png
deleted file mode 100644
index 2177570242752..0000000000000
Binary files a/docs/users-guide/images/MultiSeriesModal1.png and /dev/null differ
diff --git a/docs/users-guide/images/MultiSeriesModal2.png b/docs/users-guide/images/MultiSeriesModal2.png
deleted file mode 100644
index 1eebc28efb2ff..0000000000000
Binary files a/docs/users-guide/images/MultiSeriesModal2.png and /dev/null differ
diff --git a/docs/users-guide/images/MultiSeriesQueryBuilder.png b/docs/users-guide/images/MultiSeriesQueryBuilder.png
deleted file mode 100644
index dc45297e86bea..0000000000000
Binary files a/docs/users-guide/images/MultiSeriesQueryBuilder.png and /dev/null differ
diff --git a/docs/users-guide/images/MultiSeriesTrigger.png b/docs/users-guide/images/MultiSeriesTrigger.png
deleted file mode 100644
index c3d1a92ab368b..0000000000000
Binary files a/docs/users-guide/images/MultiSeriesTrigger.png and /dev/null differ
diff --git a/docs/users-guide/images/SQL-filter-widget.png b/docs/users-guide/images/SQL-filter-widget.png
index f4af9e26b7b63..bdbbf255b92fc 100644
Binary files a/docs/users-guide/images/SQL-filter-widget.png and b/docs/users-guide/images/SQL-filter-widget.png differ
diff --git a/docs/users-guide/images/SQLInterface.png b/docs/users-guide/images/SQLInterface.png
index 57c03b6ab76c6..4116c733e5a81 100644
Binary files a/docs/users-guide/images/SQLInterface.png and b/docs/users-guide/images/SQLInterface.png differ
diff --git a/docs/users-guide/images/multi-series-charts/add_bar_chart.png b/docs/users-guide/images/multi-series-charts/add_bar_chart.png
new file mode 100644
index 0000000000000..ff9270ec95165
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/add_bar_chart.png differ
diff --git a/docs/users-guide/images/multi-series-charts/add_series.png b/docs/users-guide/images/multi-series-charts/add_series.png
new file mode 100644
index 0000000000000..508f596e28f12
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/add_series.png differ
diff --git a/docs/users-guide/images/multi-series-charts/add_values.gif b/docs/users-guide/images/multi-series-charts/add_values.gif
new file mode 100644
index 0000000000000..013b02af5941f
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/add_values.gif differ
diff --git a/docs/users-guide/images/multi-series-charts/edit_modal.png b/docs/users-guide/images/multi-series-charts/edit_modal.png
new file mode 100644
index 0000000000000..2bc8812b99520
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/edit_modal.png differ
diff --git a/docs/users-guide/images/multi-series-charts/edit_modal_multi-series.png b/docs/users-guide/images/multi-series-charts/edit_modal_multi-series.png
new file mode 100644
index 0000000000000..261a7206e4737
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/edit_modal_multi-series.png differ
diff --git a/docs/users-guide/images/multi-series-charts/multi-series_query_builder.png b/docs/users-guide/images/multi-series-charts/multi-series_query_builder.png
new file mode 100644
index 0000000000000..0bd5ebf3ca733
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/multi-series_query_builder.png differ
diff --git a/docs/users-guide/images/multi-series-charts/notebook_editor_multi-series.png b/docs/users-guide/images/multi-series-charts/notebook_editor_multi-series.png
new file mode 100644
index 0000000000000..e337bd7087247
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/notebook_editor_multi-series.png differ
diff --git a/docs/users-guide/images/multi-series-charts/numbers_to_bar_chart.png b/docs/users-guide/images/multi-series-charts/numbers_to_bar_chart.png
new file mode 100644
index 0000000000000..276eb29c0582a
Binary files /dev/null and b/docs/users-guide/images/multi-series-charts/numbers_to_bar_chart.png differ
diff --git a/docs/users-guide/images/sql-snippets/highlight_and_save_as_snippet.gif b/docs/users-guide/images/sql-snippets/highlight_and_save_as_snippet.gif
new file mode 100644
index 0000000000000..df2336fd0f840
Binary files /dev/null and b/docs/users-guide/images/sql-snippets/highlight_and_save_as_snippet.gif differ
diff --git a/docs/users-guide/images/sql-snippets/snippet_sidebar_and_insertion.gif b/docs/users-guide/images/sql-snippets/snippet_sidebar_and_insertion.gif
new file mode 100644
index 0000000000000..7dd64b115e533
Binary files /dev/null and b/docs/users-guide/images/sql-snippets/snippet_sidebar_and_insertion.gif differ
diff --git a/docs/users-guide/sql-snippets.md b/docs/users-guide/sql-snippets.md
new file mode 100644
index 0000000000000..6d3342938e229
--- /dev/null
+++ b/docs/users-guide/sql-snippets.md
@@ -0,0 +1,84 @@
+## SQL snippets
+
+![Highlight and save as snippet](./images/sql-snippets/highlight_and_save_as_snippet.gif)
+
+**SQL snippets** are reusable bits of SQL or native queries. Anyone with permissions to the [SQL editor](writing-sql.md) can create and edit snippets, which are then available for all SQL authors.
+
+For example, if you frequently perform queries that involve multiple tables, you can save the SQL code that joins those tables as a snippet so that you (and others in your organization) can reuse that code in multiple questions.
+
+### How to create a snippet
+
+Here's a simple query with a join using the **Sample Dataset** included with Metabase.
+
+```
+SELECT *
+FROM orders AS o
+LEFT JOIN products AS p
+ON o.product_id = p.id
+```
+
+Let's save everything after FROM as a snippet to reuse in other queries.
+
+In the **SQL editor**:
+
+1. **Highlight a section of SQL** that you want to save. In this case, we'll select the following SQL code:
+```
+orders AS o
+LEFT JOIN products AS p
+ON o.product_id = p.id
+```
+
+2. **Right-click on the highlighted section.**
+3. **Select Save as snippet** to create a snippet. A modal will pop up with the SQL statement you highlighted.
+4. **Edit, name, and describe your snippet**, then click the save button.
+
+In this case, we named the snippet "Orders and Products". The snippet will now be available for anyone to use. Here's what the snippet looks like in the SQL editor:
+
+```
+SELECT *
+FROM {{snippet: Orders and Products}};
+```
+
+When writing in the SQL editor, you can now start typing `{{snippet:` and Metabase will present autocomplete options for available snippets.
+
+### Snippet menu
+
+![Snippet sidebar and insertion](./images/sql-snippets/snippet_sidebar_and_insertion.gif)
+
+The SQL editor **sidebar** has a **SQL Snippets** menu to list available and archived snippets.
+
+Click on the snippet icon on the right side of the SQL editor, below the Data Reference book icon and the Variables χ icon. Metabase will slide out a sidebar menu that lists available snippets.
+
+From the SQL Snippets menu, you can:
+
+- **Create a snippet.** Click on the `+` in the upper right of the SQL Snippets sidebar to create a new snippet.
+- **Preview snippets.** Click on the down arrow to the right of a snippet to see its description and a preview of its SQL code. There's also an option to edit the snippet.
+- **Insert a snippet.** Click on a snippet's name to insert it into your query at the cursor's current location.
+- [**Edit a snippet.**](#editing-snippets) You can change a snippet's name, description and code.
+- [**Archive and unarchive a snippet.**](#archived-snippets) From the Edit modal, you can archive a snippet, which removes the snippet from the snippet menu and autocomplete options in the SQL editor.
+
+### Editing snippets
+
+You can **edit** a snippet at any time by selecting the snippet from the SQL Snippets sidebar menu in the SQL editor. Click on the down arrow to the right of the snippet, then click **Edit**. You can change the SQL code, snippet name, and snippet description.
+
+Editing snippets is a great way to make changes to many questions at once. If, for example, you've saved the SQL code to pull user data from tables X, Y, and Z as the snippet `User Data`, but you need to change how that data is pulled (such as by adding data from another column or table), you can update the SQL code in the snippet, and all questions that use the snippet `User Data` will have the updated code.
+
+**Editing a snippet's name**. Changing a snippet's name will update the snippet's name in every question that uses that snippet. It won't break any existing questions (the underlying SQL remains unchanged), but be aware that other users may be caught off guard to discover you renamed a snippet they use frequently from "Orders and Products" to "All the things", or whatever.
+
+**Editing a snippet's SQL.** Here's where we have to remind you that with great power comes great responsibility. There is one major caveat when editing snippets, worthy of a callout:
+
+> **Caution: if you edit a snippet and include broken code, you will break every question that uses that snippet.** Make sure to test your code before saving it to an existing snippet.
+
+### Archived snippets
+
+**Archiving** snippets can help keep dated or less relevant snippets out of the way. When you archive a snippet, the snippet no longer populates in the snippet autocomplete dropdown, and the snippet will no longer show up in the main list of of snippets in the **SQL editor** sidebar.
+
+Archiving a snippet does not affect any existing queries that use the snippet, so you can safely archive a snippet without impacting any questions.
+
+You can access an archived snippet from the snippet sidebar menu by clicking on the archived button in the bottom left of the sidebar.
+
+Although there is no way to delete a snippet, you can archive and unarchive a snippet at any time.
+
+### Snippet permissions
+
+Any user who has SQL editor permissions to at least one of your connected databases will be able to view the snippets sidebar, and will be able to create, edit, and archive or unarchive any and all snippets — even snippets intended to be used with databases the user does NOT have SQL editing access to.
diff --git a/docs/users-guide/start.md b/docs/users-guide/start.md
index 58c72ba91a0bc..31635a258daef 100644
--- a/docs/users-guide/start.md
+++ b/docs/users-guide/start.md
@@ -27,6 +27,7 @@
- [Referencing your data model while writing SQL](12-data-model-reference.md)
- [Creating SQL Templates](13-sql-parameters.md)
+- [Using SQL snippets to reuse and share code](sql-snippets.md)
- [Getting automatic insights with X-rays](14-x-rays.md)
- [Setting and getting alerts](15-alerts.md)
diff --git a/docs/users-guide/writing-sql.md b/docs/users-guide/writing-sql.md
index 6c910d6d8a723..c45d4671f879c 100644
--- a/docs/users-guide/writing-sql.md
+++ b/docs/users-guide/writing-sql.md
@@ -24,12 +24,16 @@ Questions asked using SQL can be saved, downloaded, or added to a dashboard just
### Using SQL filters
-If you or someone else wrote a SQL query that includes [variables](13-sql-parameters.md), your question might have filter widgets at the top of the screen. These let you modify and filter the SQL query before it's run, changing the results you might get.
+If you or someone else wrote a SQL query that includes [variables](13-sql-parameters.md), your question might have filter widgets at the top of the screen. Filter widgets let you modify the SQL query before it's run, changing the results you might get.
![SQL filter](images/SQL-filter-widget.png)
Writing SQL queries that use variables or parameters can be very powerful, but it's also a bit more advanced, so that topic has its own page if you'd like to [learn more](13-sql-parameters.md).
+### SQL snippets
+
+You can use [SQL snippets](sql-snippets.md) to save, reuse, and share SQL code across multiple questions that are composed using the SQL editor.
+
---
## Next: Creating charts
diff --git a/frontend/src/metabase-lib/lib/queries/StructuredQuery.js b/frontend/src/metabase-lib/lib/queries/StructuredQuery.js
index 5ef28c49530f0..cc47df08172fc 100644
--- a/frontend/src/metabase-lib/lib/queries/StructuredQuery.js
+++ b/frontend/src/metabase-lib/lib/queries/StructuredQuery.js
@@ -816,9 +816,14 @@ export default class StructuredQuery extends AtomicQuery {
return [].concat(...queries.map(q => q.filters()));
}
- filterFieldOptionSections(filter?: ?(Filter | FilterWrapper)) {
+ filterFieldOptionSections(
+ filter?: ?(Filter | FilterWrapper),
+ { includeSegments = true } = {},
+ ) {
const filterDimensionOptions = this.filterDimensionOptions();
- const filterSegmentOptions = this.filterSegmentOptions(filter);
+ const filterSegmentOptions = includeSegments
+ ? this.filterSegmentOptions(filter)
+ : [];
return filterDimensionOptions.sections({
extraItems: filterSegmentOptions.map(segment => ({
name: segment.name,
diff --git a/frontend/src/metabase-lib/lib/queries/structured/Aggregation.js b/frontend/src/metabase-lib/lib/queries/structured/Aggregation.js
index 34226a6776f1b..52009696a9f33 100644
--- a/frontend/src/metabase-lib/lib/queries/structured/Aggregation.js
+++ b/frontend/src/metabase-lib/lib/queries/structured/Aggregation.js
@@ -6,7 +6,7 @@ import { t } from "ttag";
import { TYPE } from "metabase/lib/types";
-import { isStandard, isMetric, isCustom } from "metabase/lib/query/aggregation";
+import * as AGGREGATION from "metabase/lib/query/aggregation";
import type { Aggregation as AggregationObject } from "metabase/meta/types/Query";
import type StructuredQuery from "../StructuredQuery";
@@ -160,21 +160,21 @@ export default class Aggregation extends MBQLClause {
* Returns true if this is a "standard" metric
*/
isStandard(): boolean {
- return isStandard(this);
+ return AGGREGATION.isStandard(this);
}
/**
* Returns true if this is a metric
*/
isMetric(): boolean {
- return isMetric(this);
+ return AGGREGATION.isMetric(this);
}
/**
* Returns true if this is custom expression created with the expression editor
*/
isCustom(): boolean {
- return isCustom(this);
+ return AGGREGATION.isCustom(this);
}
// STANDARD AGGREGATION
diff --git a/frontend/src/metabase/admin/datamodel/containers/MetricForm.jsx b/frontend/src/metabase/admin/datamodel/components/MetricForm.jsx
similarity index 56%
rename from frontend/src/metabase/admin/datamodel/containers/MetricForm.jsx
rename to frontend/src/metabase/admin/datamodel/components/MetricForm.jsx
index 63a30e32076da..2d14ce9356d63 100644
--- a/frontend/src/metabase/admin/datamodel/containers/MetricForm.jsx
+++ b/frontend/src/metabase/admin/datamodel/components/MetricForm.jsx
@@ -1,5 +1,7 @@
import React, { Component } from "react";
import { Link } from "react-router";
+import { reduxForm } from "redux-form";
+import cx from "classnames";
import FormLabel from "../components/FormLabel";
import FormInput from "../components/FormInput";
@@ -8,16 +10,8 @@ import FieldSet from "metabase/components/FieldSet";
import PartialQueryBuilder from "../components/PartialQueryBuilder";
import { t } from "ttag";
import { formatValue } from "metabase/lib/formatting";
-
-import { reduxForm } from "redux-form";
-
import * as Q_DEPRECATED from "metabase/lib/query";
-import cx from "classnames";
-import Question from "metabase-lib/lib/Question";
-import Metadata from "metabase-lib/lib/metadata/Metadata";
-import Table from "metabase-lib/lib/metadata/Table";
-
@reduxForm(
{
form: "metric",
@@ -55,11 +49,7 @@ import Table from "metabase-lib/lib/metadata/Table";
)
export default class MetricForm extends Component {
renderActionButtons() {
- const {
- invalid,
- handleSubmit,
- table: { db_id: databaseId, id: tableId },
- } = this.props;
+ const { invalid, handleSubmit } = this.props;
return (
{t`Cancel`}
);
}
- componentDidMount() {
- if (!this.props.fields.definition.value) {
- this.setDefaultQuery();
- }
- }
- componentDidUpdate() {
- if (!this.props.fields.definition.value) {
- this.setDefaultQuery();
- }
- }
-
- setDefaultQuery() {
- const {
- fields: {
- definition: { onChange },
- },
- metadata,
- table: { id: tableId, db_id: databaseId },
- updatePreviewSummary,
- } = this.props;
-
- if (!metadata) {
- // we need metadata to generate a default question
- return;
- }
-
- const query = Question.create({ databaseId, tableId, metadata }).query();
- const table = query.table();
- let queryWithFilters;
- if (table.entity_type === "entity/GoogleAnalyticsTable") {
- const dateField = table.fields.find(f => f.name === "ga:date");
- if (dateField) {
- queryWithFilters = query
- .filter(["time-interval", ["field-id", dateField.id], -365, "day"])
- .aggregate(["metric", "ga:users"]);
- }
- } else {
- queryWithFilters = query.aggregate(["count"]);
- }
-
- if (queryWithFilters) {
- onChange(queryWithFilters.query());
- updatePreviewSummary(queryWithFilters.datasetQuery());
- }
- }
-
render() {
const {
fields: { id, name, description, definition, revision_message },
- metadata,
- table,
handleSubmit,
previewSummary,
updatePreviewSummary,
@@ -142,47 +84,24 @@ export default class MetricForm extends Component {
title={isNewRecord ? t`Create Your Metric` : t`Edit Your Metric`}
description={
isNewRecord
- ? t`You can create saved metrics to add a named metric option to this table. Saved metrics include the aggregation type, the aggregated field, and optionally any filter you add. As an example, you might use this to create something like the official way of calculating "Average Price" for an Orders table.`
+ ? t`You can create saved metrics to add a named metric option. Saved metrics include the aggregation type, the aggregated field, and optionally any filter you add. As an example, you might use this to create something like the official way of calculating "Average Price" for an Orders table.`
: t`Make changes to your metric and leave an explanatory note.`
}
>
- {metadata && table && (
- a.short !== "rows"),
- metrics: (table.metrics || []).filter(
- m => m.googleAnalyics,
- ),
- },
- ),
- },
- })
- }
- tableMetadata={table}
- previewSummary={
- previewSummary == null
- ? ""
- : t`Result: ` + formatValue(previewSummary)
- }
- updatePreviewSummary={updatePreviewSummary}
- {...definition}
- />
- )}
+