Sub topic 3
Drilling down and up in a visual
This chapter assumes you can build a bar chart, column chart, or matrix in Power BI Desktop. It also assumes you have a date table related to a fact table, and that you have read the previous chapter on hierarchies. Here you will use a hierarchy to move through levels of detail inside one visual, and learn what Power BI does to the data at each step.
What drill-down does
Drill-down changes the level of detail a single visual shows. You put a hierarchy (for example Category > Subcategory > Product) on the visual's axis. The visual first shows the top level. When the reader drills down, the visual shows the next level. Drill-up goes back.
The key point is that the report page does not change. Other visuals on the page do not switch levels. Only the visual you drill in changes its grouping.
Drill-down depends on two things:
- A hierarchy, or several fields placed in order in the same well (Axis, Rows, Columns, or Legend). A single field has nothing to drill into.
- Drill mode being turned on for the visual. You turn it on with the drill-down arrow buttons in the visual header.
The header buttons
When you hover over or select a visual that has a hierarchy, the visual header shows up to four drill controls.
| Button | Icon | What it does |
|---|---|---|
| Drill mode | Single down arrow | Turns drill mode on or off. When on, clicking a data point drills into that point. |
| Drill up | Up arrow | Goes back one level. |
| Go to the next level | Double down arrow | Moves every item to the next level at once. It does not filter. |
| Expand all down one level | Forked arrow | Shows the next level beneath the current one, keeping both. This is covered in the next chapter. |
The buttons that appear depend on the visual. If the visual has only one field in the axis, none of them appear.
Two ways to drill down
Drill into one data point
- Select the drill mode arrow (single down arrow). It turns dark to show it is active.
- Click a data point, such as the Bikes column.
- The visual now shows the next level, but only for Bikes.
This is a filtered drill. Power BI adds the clicked value as a filter to the visual and groups by the next field.
You can also skip drill mode. Right-click a data point and choose Drill down. The result is the same, and drill mode stays off.
Go to the next level for all items
Select the double down arrow. The visual moves to the next level and shows every item at that level, with no filter applied. If you started at Category, you now see all Subcategories across all Categories.
Drill-down on one point filters. Go to the next level does not. Use the first when you ask "what is inside Bikes?" and the second when you ask "how do all subcategories compare?"
Drill-up
Select the up arrow to go back one level. Drill-up also removes the filter that drill-down added. If you drilled into Bikes and then into Road Bikes, drilling up once shows the Bikes subcategories again, and drilling up twice returns the Category level.
What happens to filter context
Each drill-down step changes the filter context inside the visual. The previous chapters on filter context apply here directly.
Suppose a column chart has the hierarchy Category > Subcategory > Product on its axis and the measure [Total Sales] as its value. After the reader drills into Bikes and then into Road Bikes, the visual evaluates [Total Sales] once for each product. For each product, the filter context contains:
- Category = Bikes
- Subcategory = Road Bikes
- Product = that product
The measure is the same. Only the filter context differs. This is why a well-written measure works at every level of the hierarchy without changes.
Because the code fence rule forbids this form, here is the same idea as a proper diagram.
Drill-down and other visuals on the page
Drilling down in a visual does not by itself filter other visuals. The visual still shows the same data, grouped differently.
Cross-filtering is different. If you click a column in a drilled-down visual with drill mode off, Power BI cross-filters the other visuals. At the Subcategory level, clicking Road Bikes filters the rest of the page by Subcategory = Road Bikes. Whether the other visuals filter or highlight depends on the Edit interactions settings you met earlier.
This gives you a way to tell the two actions apart:
- Drill mode on: a click drills the visual.
- Drill mode off: a click selects the point and cross-filters other visuals.
A common mistake is to leave drill mode on and then wonder why the other visuals do not respond when you click. Check whether the single down arrow is dark.
Using a date hierarchy
Power BI creates an automatic date hierarchy for date columns when auto date/time is on. The levels are Year > Quarter > Month > Day. If you have a date table, build your own hierarchy instead.
A date table hierarchy has advantages:
- You choose the levels, such as Year > Month > Date.
- You can sort Month by month number so months do not appear alphabetically.
- It works with the time-intelligence measures in your model.
If drilling a date field gives you unsorted months, set Sort by column on the Month Name column to the Month Number column. Do this in the model, then drill again.
Drill-down in a matrix
A matrix supports drill-down in rows and in columns. Put a hierarchy in Rows. Header buttons appear, and so do small expand and collapse icons next to each row header if you turn them on in the format pane.
A matrix has three extra behaviors:
- The drill-down button applies to the field well that is active. Use the right-click menu to choose rows or columns if both contain hierarchies.
- Expanding a row header with the plus icon shows the next level under that row only. This is an expand action, not a drill action.
- Subtotals can be shown at each level. Turn them on or off in the format pane under Row subtotals.
Making a measure react to the level
Sometimes you want a measure to behave differently at different levels. Use ISINSCOPE, which returns TRUE when a column is the one the visual is currently grouping by.
Level Label =
IF (
ISINSCOPE ( Product[Product Name] ), "Product",
IF (
ISINSCOPE ( Product[Subcategory] ), "Subcategory",
IF ( ISINSCOPE ( Product[Category] ), "Category", "Total" )
)
)Check the lowest level first. At the Product level, Subcategory and Category are also in scope, so a check starting at Category would always return "Category" once you drill past it. At the grand total row, none of the columns are in scope, so the measure returns "Total".
You can place this measure in a table or in a card title to see how the scope changes as you drill. A typical use is a ratio that makes sense at one level but not at another, for example showing a share of parent only below the top level.
Share of Parent =
VAR _Current = [Total Sales]
VAR _Parent =
IF (
ISINSCOPE ( Product[Product Name] ),
CALCULATE ( [Total Sales], ALLSELECTED ( Product[Product Name] ) ),
IF (
ISINSCOPE ( Product[Subcategory] ),
CALCULATE ( [Total Sales], ALLSELECTED ( Product[Subcategory], Product[Product Name] ) ),
CALCULATE ( [Total Sales], ALLSELECTED ( Product[Category], Product[Subcategory], Product[Product Name] ) )
)
)
RETURN
DIVIDE ( _Current, _Parent )This measure removes filters on the current level and every level below it, so the denominator is the total of the parent group. Check the results against a table first. ALLSELECTED keeps filters from outside the visual, such as slicers, so the share stays correct when a slicer is active.
Edge cases and limits
- Blank values in a level. If a Subcategory is blank for some products, the drill shows a blank group. Fix blanks in the source or model, not in the visual.
- Unbalanced hierarchies. If some branches have fewer levels, drilling still goes to the next field, and you see blank or repeated labels. Fill the missing levels in the model.
- Many-to-many hierarchy paths. If a Product belongs to two Subcategories, one row appears under each. Totals may not add up. Check the model relationship before blaming the visual.
- Reset on page change. Drill state is not saved when the reader leaves the page, unless a bookmark captures it. Bookmarks do capture the drill level of visuals when the bookmark's Data option is on.
- Visual types. Drill-down works in column, bar, line, area, pie, donut, treemap, matrix, and several others. Cards, slicers, and basic tables do not drill.
- Row limits. A drilled visual still obeys the visual's data limits. A very large lower level can be truncated or slow.
Putting it together: a worked example
Build a column chart with a hierarchy and test each button.
- Create a hierarchy named Product Hierarchy in the Product table with Category, Subcategory, and Product Name.
- Add a clustered column chart. Put Product Hierarchy on the X-axis and
[Total Sales]on the Y-axis. - Add a table beside it with Product Name and
[Total Sales], and add theLevel Labelmeasure to a card. - Select the chart. The header now shows the drill buttons.
- Turn on drill mode. Click the Bikes column. The chart now shows Bikes subcategories.
- Click Road Bikes. The chart shows products in Road Bikes.
- Select drill up twice. You are back at Category.
- Turn drill mode off and click the Bikes column. The table beside it filters to Bikes products. This is cross-filtering, not drilling.
- Select the double down arrow. The chart shows all subcategories without a Category filter.
Compare steps 5 and 9. Both end at the Subcategory level, but only step 5 carries the Bikes filter.
Exercise
A column chart has Category > Subcategory on its axis. A reader clicks the Mountain Bikes column with drill mode off, and the other visuals on the page filter to Mountain Bikes. The reader expected the chart itself to show products inside Mountain Bikes. What is the cause, and what are two ways to get the intended result?
Show answer
With drill mode off, a click selects the data point and cross-filters other visuals. It does not drill. To drill into Mountain Bikes, either turn drill mode on (single down arrow) and click the column, or right-click the column and choose Drill down. Both add the filter for that point and show the next level in the same visual.
Exercise
You use the double down arrow (go to the next level) on a chart that starts at Category. What does the chart show, and how does it differ from drilling into the Bikes column?
Show answer
It shows every Subcategory across all Categories, with no Category filter. Drilling into Bikes shows only the Bikes subcategories, because the click adds Category = Bikes to the visual's filter context.
Exercise
Your Level Label measure always returns "Category" even when the visual shows products. What is the most likely error in the measure?
Show answer
The checks are in the wrong order. At the Product level, the Category column is also in scope, so a measure that tests Category first returns "Category" immediately. Test the lowest level (Product Name) first, then Subcategory, then Category.