Guides
Data exploration
Building UI with drilldowns

Drilldowns

Drilldowns are a powerful feature to facilitate data exploration. It allows building an interface to let users dive deeper into visualizations and data tables. See ResultSet.drillDown() on how to use this feature on the client side.

A drilldown is defined on the measure level in your data model. It’s defined as a list of dimensions called drill members. Once defined, these drill members will always be used to show underlying data when drilling into that measure.

Let’s consider the following example of our imaginary e-commerce store. We have the orders cube, which describes orders in our store. It’s connected to users and products.

YAML
JavaScript
cube(`orders`, {
  sql_table: `orders`,
 
  joins: {
    users: {
      relationship: `many_to_one`,
      sql: `${CUBE}.user_id = ${users.id}`,
    },
 
    products: {
      relationship: `many_to_one`,
      sql: `${CUBE}.product_id = ${products.id}`,
    },
  },
 
  measures: {
    count: {
      type: `count`,
      // Here we define all possible properties we might want
      // to "drill down" on from our front-end
      drill_members: [id, status, products.name, users.city],
    },
  },
 
  dimensions: {
    id: {
      type: `number`,
      sql: `id`,
      primary_key: true,
      public: true,
    },
 
    status: {
      type: `string`,
      sql: `status`,
    },
  },
});

You can follow this tutorial (opens in a new tab) to learn more about building a UI for drilldowns.