1
votes

Is drillthrough supported in a Power BI Custom Visual?

enter image description here

If so, could you please provide a snippet of your visual.ts file to show how it's to be used? I've been searching for documentation on it and nothing has turned up - I'm beginning to think its not available for developers yet and only for the official visuals provided by Power BI.

2

2 Answers

2
votes

It seems like Drillthrough is not supported yet.

Response from Microsoft after posting question in forum: http://community.powerbi.com/t5/Developer/Use-Drillthrough-in-Custom-Visual/m-p/270240#M8199

0
votes

Good news! As of API v2.2.0

Custom visuals now support drillthrough

The official developer blog mentions it in the Nov 2018 post.

To enable drillthrough, the visual just need to support Context Menu (detailed instructions in Adding Context-Menu to the Bar Chart). Once a context menu event is triggered on anything sending a dataPoint.selectionId, the menu will include a drillthrough option.

If you are using D3, and store your SVG as this.svg in your code, the basic code can look something like:

this.svg.on('contextmenu', () => {
  const mouseEvent: MouseEvent = d3.event as MouseEvent;
  const eventTarget: EventTarget = mouseEvent.target;
  let dataPoint = d3.select(eventTarget).datum();
  this.selectionManager.showContextMenu(dataPoint? dataPoint.selectionId : {}, {
    x: mouseEvent.clientX,
    y: mouseEvent.clientY
  });
  mouseEvent.preventDefault();
});

(copied from custom visuals official documentation - as linked above)

Note how the selection.id is passed in the selectionManager.showContextMenu() call - that's what enables drillthrough.


Disclaimer: I'm a Microsoft employee, working in one of Power BI development teams. This answer is posted based on my personal knowledge and experience, and is not endorsed or approved by Microsoft in any way.