Drilldown With Multiple Attributes

Return several columns from one drilldown, and filter a drilldown on more than one column.

1. Drilling Down to Show Multiple Columns

Often the detail a reader wants spans several columns. Building on the previous example, say that instead of just state we also want city and customerName — all three at once.

Before

Drilldown returning only the state column

After

Drilldown returning state, city, and customer name

Step 1: Fetch More Columns in the Drilldown Query

Before

SQL
SELECT country, state, COUNT(customerNumber) as numberOfCustomers
FROM [customers.xlsx]
WHERE country=:_harbour_drill_:country:undefined:
GROUP BY country, state
ORDER BY COUNT(customerNumber) DESC

After

SQL
SELECT country, state, city, customerName,
       COUNT(customerNumber) as numberOfCustomers
FROM [customers.xlsx]
WHERE country=:_harbour_drill_:country:undefined:
GROUP BY country, state, city, customerName
ORDER BY COUNT(customerNumber) DESC

Update the query in drilldown mode and click Save.

Editing the multi-column drilldown query

Now when a reader clicks a country, all three columns — state, city, and customerName — are fetched and displayed.

The multi-column drilldown result

2. Filtering a Drilldown on Multiple Columns

Say the table initially shows country, state, and the number of customers in each state. When a reader clicks a row, the drilldown should show detail by city.

Before

The table before drilling into city

After

The table drilled down to city level

Filtering the drilldown on country alone won't work here. The filter has to apply to both country and state, so only the data relevant to the clicked row is fetched.

The chart itself is built with this query:

SQL
SELECT country, state, COUNT(customerNumber) as numberOfCustomers
FROM [customers.xlsx]
GROUP BY country, state
ORDER BY COUNT(customerNumber) DESC
The base table showing country and state

So the drilldown query becomes:

SQL
SELECT country, state, city, COUNT(customerNumber) as numberOfCustomers
FROM [customers.xlsx]
WHERE country=:_harbour_drill_:country:undefined:
  AND state=:_harbour_drill_:state:undefined:
GROUP BY country, state, city
ORDER BY COUNT(customerNumber) DESC
ℹ️ Two Things Changed There are now two drilldown hints — one for country, one for state — separated by AND. And the columns used in the hints appear in both the SELECT and GROUP BY clauses.
The city-level drilldown result
ℹ️ Where the City Attribute Appears The city attribute only shows up in the panel once you have drilled down at least once.