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

4 REPLIES 4
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