Sub topic 6
Creating a drill-through page
This chapter assumes you can build tables and bar charts in Power BI Desktop, you have a star-schema model with a Customer table, and you know how to write a simple DAX measure. Drill-through lets a reader right-click a data point and jump to a detail page. That page is filtered to the item they chose. Here you build one for customers.
How the page receives its filter
A drill-through page is an ordinary report page with one or more fields in its Drill-through well. When a reader right-clicks a visual that shows one of those fields, Power BI offers the page in the Drill through menu. The selected value is passed as a filter, so every visual on the page shows only that value's data.
Build the page
- Add a new page and name it
Customer Detail. Use a clear name, because it appears in the right-click menu. - Open the Visualizations pane and select the format (paint roller) icon. Under Page information, you can set the page type if your version offers it. Otherwise, continue with the next step.
- In the Fields pane, drag
Customer[Customer Name]into the Add drill-through fields here well. - Add the visuals that answer "what is this customer doing?". Good choices are a card for total sales, a line chart of sales by month, and a table of recent orders.
- Add a title text box or use a dynamic title (see below).
Once the field is in the well, Power BI adds a back button automatically in the top-left corner. Do not delete it. The next chapter covers customizing it.
Test it
- Go back to a summary page with a bar chart of
Total SalesbyCustomer[Customer Name]. - In Power BI Desktop, right-click a bar, then choose Drill through and Customer Detail.
- In the published service, the same right-click works. In Desktop, Ctrl+click is not required.
The detail page now shows only that customer.
Add a dynamic title
A title that names the selected customer confirms to the reader that the filter worked. Create this measure on the Customer table:
Drill-through Title =
"Orders for " & SELECTEDVALUE ( Customer[Customer Name], "multiple customers" )SELECTEDVALUE returns the name when exactly one customer is in filter context. If the filter holds zero or several customers, it returns the fallback text. That happens when someone opens the page directly from the page tabs. Bind the measure to a card visual or to a visual title through the fx button beside Title.
Choose drill-through fields carefully
- The field you add must come from the same column the source visual uses, or from a column related to it in a way that filters properly.
- You can add more than one field. A visual must contain every field to trigger the page only if you turn off the OR behavior. By default, a visual with any one of the fields will show the page in the menu.
- Use a descriptive column, such as the name, as the drill-through field. Using a key column hides what is selected from the reader.
Common mistakes
- The menu shows nothing. The source visual does not contain the drill-through field. A chart showing
Product[Category]will not offer a page built onCustomer[Customer Name]. - Measures in the field well. The well accepts columns. A measure there will not filter anything.
- The page shows all customers. The reader opened the page by clicking its tab. No filter was passed. Use the dynamic title to make this visible.
Exercise
A reader right-clicks a bar for "Contoso Ltd" on a chart showing Product[Category], and the Customer Detail page, built on Customer[Customer Name], does not appear in the menu. Why, and what is one way to fix it?
Show answer
The visual does not contain the Customer Name field, so Power BI cannot pass a customer filter. Fix it by using a visual that shows Customer[Customer Name], or by adding a drill-through field to the page that exists in the source visual, such as Product[Category] on a separate product detail page.