Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
alexpokerface
Frequent Visitor

How to detect drill mode

Hi,

a quick question:

In the Power BI custom visuals API, is there any way to detect whether the visual is currently in drill mode (as opposed to normal selection mode)?

Thanks and kind regards,

Alex

5 REPLIES 5
asafcohen
Microsoft Employee
Microsoft Employee

Hi @alexpokerface ,
As @dm-p said there is no simple straight forward method to check this. However, you can do try the following, all inside update():

1. dataView.metadata.dataRoles.drillableRoles — a map of role name → the DrillType[] currently available for it. When Drill Up is available for a role, the user has drilled down at least one level, which is the reliable "am I in a drilled-down state" signal:

TypeScript
 
import powerbi from "powerbi-visuals-api";
import DrillType = powerbi.DrillType;

public update(options: powerbi.extensibility.visual.VisualUpdateOptions😞 void {
    const dataRoles = options.dataViews?.[0]?.metadata?.dataRoles;
    const available = dataRoles?.drillableRoles?.["category"] ?? []; // role name from capabilities "drilldown".roles

    const isDrilledDown = available.indexOf(DrillType.Up) >= 0;   // Drill Up exists => below the top level
    const canDrillDown  = available.indexOf(DrillType.Down) >= 0; // more levels below
    const drillDisabled = dataRoles?.isDrillDisabled === true;    // drilling currently turned off
}

2. After any drill, Power BI just calls update() again with a new DataView. Read the level from the data — categorical: the number of categorical.categories and each categories[i].source.displayName (e.g., Year → Quarter → Month); matrix: the depth of matrix.rows.levels and each node's level. Note the category value type can change per level (Date at the top, string lower down), so guard with categories[i].source.type before parsing.

3. To drive drilling from your own UX (e.g., double-click to drill down), call host.drill(args) (API 4.7.0+), and optionally host.setCanDrill(true/false) (5.7.0+) to enable/disable it at runtime.


Good luck,
Asaf.

 

References

Gautam_Kumar01
Post Patron
Post Patron

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 😊

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.

Unfortunately that code looks like an hallucination - there's nothing in the APIs matching these types or methods.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




dm-p
Super User
Super User

Hi @alexpokerface,

 

Unfortunately there's no simple method to check this. I think the only way to detect this would be to check the dataView.metadata for the presence of drillableRoles, and perhaps, based on your knowledge of your setup, whether the resulting state means you're somewhere in the hierarchy (e.g, if there's no DrillType.Up available on a role, then you are at the top of your hierarchy, and therefore you aren't in a drill state.

 

The pattern for interrogation of drill state here in the docs may provide a starting point for you.

 

Good luck,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors