Sub-query example

This example has been created to help walk through how sub-query works.

In the dashboard, we created 2 data tables:

  • US State Population

  • County Population

Our ‘County Population’ chart shows the population for every state in the United States.

Our second chart, ‘US State Population’ shows the total population for every State in the United States but has been filtered to only show the top 10 most populous states.

When we use the chart, ‘US State Population’, to filter our ‘County Population’ chart we will only see counties in the top 10 most populous states.

This works by running the SQL query of the sub-chart, ‘US State Population’, and using the values from this chart to populate the filter for the ‘County Population’ chart.

If a ‘Like’ filter is used, a single value from the ‘US State Population’ data table will used. This value will be from the first row in the first column in the table which in this case happens to be California.

The resulting ‘County Population’ table showing counties in California only.

Chart Notification shows that a filter of ‘California’ has been applied.

If an ‘In’ filter is used, multiple values from the ‘US State Population’ data table will be used. These will be values from the first column of the table - in this case, the 10 top states by population that we filtered this table on.

Chart Notification shows that the ‘County Population’ table has been filtered on 10 states - the 10 most populous.

The resulting ‘County Population’ table showing only counties in the Top 10 most populous states.