Forum Discussion
How to detect drill mode
Hi Alex, alexpokerface
Yes, you can detect drill mode in custom visuals.
How it works:
When a user clicks "Drill Down" in Power BI, the visual gets a new update call. In that update, Power BI tells your visual what mode it's currently in through the DataView metadata.
The Code:
Put this inside your `update(options: VisualUpdateOptions)` method:
```typescript
import { DrillState } from "powerbi-visuals-api";
public update(options: VisualUpdateOptions) {
const dataView = options.dataViews?.[0];
if (!dataView) return;
const drillState = dataView.metadata?.drillState;
switch(drillState) {
case DrillState.DrillDown:
// User clicked Drill Down on a category
// Example: Year -> Quarter -> Month
this.renderDrillView(dataView);
break;
case DrillState.Expand:
// User clicked + icon to expand tree
this.renderExpandedView(dataView);
break;
case DrillState.None:
default:
// Normal selection mode
I hope you got the answer is any problem you can freely to ask here , Thanks 😊
- alexpokerface1 month agoFrequent Visitor
Thanks for the snippet! I checked the current and recent versions of the powerbi-visuals-api, and neither DrillState nor dataView.metadata.drillState exists in the public API. If this comes from an internal or experimental build, that would be interesting — but in the official contract, the property isn’t available.
- dm-p1 month agoSuper User
Unfortunately that code looks like an hallucination - there's nothing in the APIs matching these types or methods.