Sub topic 6
Creating a drill-through page
This chapter walks through building a drill-through page in Power BI Desktop. It assumes you can build bar charts, tables, and matrices, that your model is a star schema with a date table, and that you can write simple DAX measures. You should also know that a visual's data comes from filter context, which earlier chapters covered.
What you are building
A drill-through page is a report page that receives a filter from another page. A reader right-clicks a data point, such as one customer in a bar chart, and chooses Drill through. Power BI opens the detail page and filters it to that customer.
The detail page declares which columns it accepts. These columns go in the Drill-through well. Power BI then adds a Drill through entry to the context menu of any visual on another page that uses one of those columns.
Step 1: Create the detail page
- In Report view, add a new page.
- Rename it to something readers will recognize in the menu, such as
Customer Detail. The page name appears in the Drill through submenu. - Select the page background, not a visual, so the Visualizations pane shows the page's settings.
Step 2: Add the drill-through field
- With nothing selected on the page, open the Visualizations pane and find the Drill through well.
- Drag
Customer[Customer Name]from the Fields pane into Add drill-through fields here. - Confirm that Keep all filters is set the way you want. The next chapter covers that setting in detail.
After you add the field, Power BI creates a page-level filter on Customer Name that is empty until a reader drills through. Power BI also adds a back button to the top-left corner of the page automatically. The following chapter shows how to build and style your own.
The field you choose should be a column with a clear identity, such as a name or key. A column with many repeated values, such as Country, also works. The detail page then shows data for the whole country.
Step 3: Build the detail content
Build the page as you would any report page. Everything on the page is filtered by the drill-through value. Useful content for a customer detail page includes:
- Card visuals for total sales, order count, and average order value.
- A table of orders with date, product, and amount.
- A line chart of sales by month.
Use measures that already exist in your model. The filter flows through relationships the same way a slicer selection would. If the Customer table filters Sales in your model, every visual that uses Sales shows only that customer.
Add a dynamic title
A page that shows data for an unnamed filter confuses readers. Put the chosen customer in the title with a measure. Create this measure and place it in a card or in a text box that supports field values:
Drill-through Title =
"Orders for " & SELECTEDVALUE ( Customer[Customer Name], "multiple customers" )SELECTEDVALUE returns the value when exactly one Customer Name is in filter context. When no customer is filtered, or several are, it returns the second argument. This matters in two cases. First, when you open the page directly from the page tabs, nothing has been selected, so the title reads "Orders for multiple customers". Second, when a reader selects several data points before drilling through, the page receives several values.
Step 4: Test the drill-through
- Go to a source page with a visual that contains
Customer Name, for example a bar chart of sales by customer. - Right-click a bar.
- Choose Drill through, then Customer Detail.
In Desktop you can also hold Ctrl and click the back button on the detail page to follow its navigation behavior while testing. In the Power BI service, a plain click works.
The detail page opens with the customer already filtered. Check the Filters pane on the detail page. The drill-through field appears there with the selected value.
What a source visual must contain
The menu entry appears only when the data point carries the drill-through field. These cases behave differently:
| Source visual | Drill through available? | Reason |
|---|---|---|
| Bar chart with `Customer Name` on the axis | Yes | The data point has a `Customer Name` value. |
| Bar chart with only `Country` on the axis | No | The point has no `Customer Name`, so there is nothing to pass. |
| Table with `Customer Name` as a column | Yes | Each row has a customer value. |
| Card showing a total | No | A card has no field to identify. |
| Visual using a measure in a different table, with no customer column | No | Measures alone do not carry a field value. |
If you want drill-through from a visual that shows only Country, add Country to the Drill-through well as well. A page can accept several fields.
Passing a filter through a hierarchy
If a visual uses a hierarchy and sits at the Category level, the data point carries only Category. A drill-through page whose field is Product Name will not appear. The reader must drill down to the product level first, or the drill-through page must accept Category. Plan the field choices with the levels in mind.
Hiding the page from navigation
Detail pages are rarely meant to be opened directly. Right-click the page tab and choose Hide page. A hidden page is still available through the Drill through menu. Hidden pages are not visible in the page tab strip in reading view.
You can still reach a hidden page in Desktop by selecting it in the tab strip, where it appears with an eye icon with a line through it.
Reading the page filter correctly
Power BI applies the drill-through value as a page-level filter. This has consequences:
- Visuals on the page cannot easily show values for other customers. If you want a comparison against all customers, write a measure that removes the filter, for example with
ALL ( Customer )insideCALCULATE. - Slicers on the detail page still work. They combine with the drill-through filter by intersection.
- Filtering a drill-through field with the Filters pane directly is possible, but it changes what the page does when reached by drill-through.
Common mistakes
- Dragging the field to a visual's filter instead of the Drill-through well. The page then filters itself and never appears in menus.
- Adding a visual-level filter that conflicts with the drill-through value. The page opens blank.
- Forgetting that relationships must allow the filter to reach the data. If
Customerdoes not filterSales, the detail visuals show unfiltered totals. - Using a column from a disconnected table. The filter reaches no visuals.
Exercise
A bar chart on the Overview page shows sales by Category and Subcategory in a hierarchy. Your drill-through page accepts only Product[Product Name]. A reader right-clicks a bar at the Subcategory level and finds no Drill through option. Give two ways to fix this.
Show answer
The data point at the Subcategory level carries Subcategory (and its parent levels) but no Product Name, so it cannot match the Drill-through well. Fix 1: have the reader drill down one more level to Product, where each point carries Product Name. Fix 2: add Product[Subcategory] to the Drill-through well of the detail page (or build a second detail page for it), so points at that level match.
Exercise
You open the Customer Detail page directly from its tab and the title card reads "Orders for multiple customers". Is this a bug? Why does it happen?
Show answer
No. No customer filter is applied when the page is opened directly, so more than one Customer Name is in filter context. SELECTEDVALUE then returns its alternate result, "multiple customers". The title shows the customer's name only after a drill-through supplies a single value.