Explore this snippet with some demo data here.
Bar and line charts can communicate a lot of info on a single chart. They require all of the elements of a bar chart:
- 2 categorical or temporal columns - 1 for the x-axis and 1 for stacked bars
- 2 numeric columns - 1 for the bar and 1 for the line
SELECT AGG_FN(<COLUMN>) OVER (PARTITION BY <CAT_COLUMN1>, <CAT_COLUMN2>) as bar_metric, <CAT_COLUMN1> as x_axis, <CAT_COLUMN2> as cat, AGG_FN(<COLUMN2>) OVER (PARTITION BY <CAT_COLUMN1>) as line FROM <TABLE>
AGG_FNis an aggregation function like
COLUMNis the column you want to aggregate to get your bar chart metric. Make sure this is a numeric column.
COLUMN2is the column you want to aggregate to get your line chart metric. Make sure this is a numeric column.
CAT_COLUMN2are the groups you want to compare. One will go on the x axis and the other on the colors of the bar chart. Make sure these are categorical or temporal columns and not numerical fields.
In this example with some example data we’ll look at some sample data of users that were successful and unsuccessful at a certain task over a few days. We’ll show the count of users by their outcome, then show the overall success rate for each day.