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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Grzy7316
Frequent Visitor

Adding Selection To Custom Visual

I have a custom visual I am working on where I am building out a map with leaflet & trying to add in the ability to click on the map and have it filter the other visual on the page. 

I am looking at the following docs
https://github.com/PowerBi-Projects/PowerBI-visuals/blob/master/Visual/Selection.md
https://learn.microsoft.com/en-us/power-bi/developer/visuals/selection-api



Whjen I try to add this 

const categorySelectionId = this.host.createSelectionIdBuilder()

into either my update or constructor for my visual I get the error  

Property 'createSelectionIdBuilder' does not exist on type 'IVisualHost'.

I am running  powerbi-visuals-tools version - 5.5.1 and have the following versions  in package.json 

    "powerbi-visuals-api": "~5.3.0",
    "powerbi-visuals-utils-dataviewutils": "^6.1.0",
    "powerbi-visuals-utils-formattingmodel": "6.0.0",
    "powerbi-visuals-utils-interactivityutils": "^6.0.4"


What am I doing wrong here? 

1 REPLY 1
Anonymous
Not applicable

Hi, @Grzy7316 

1.Firstly, have you correctly imported the relevant variables:

 

import IVisual = powerbi.extensibility.IVisual;
import IVisualHost = powerbi.extensibility.visual.IVisualHost;

 

2.Secondly, I recommend checking whether you have created class properties for both the host and the selection manager.

 

private host: IVisualHost;
private selectionManager: ISelectionManager;

 

For further details, please refer to:

vlinyulumsft_0-1730273854250.png

https://learn.microsoft.com/en-us/power-bi/developer/visuals/selection-api#create-an-instance-of-the...

3.Next, please refer to the following code for the IVisualHost interface services:

 

export interface IVisualHost extends extensibility.IVisualHost {
        createSelectionIdBuilder: () => visuals.ISelectionIdBuilder;

 

vlinyulumsft_1-1730273938327.png

For further details, please refer to:

powerbi-visuals-api/src/visuals-api.d.ts at main · microsoft/powerbi-visuals-api · GitHub

Visual API for Power BI Visuals - Power BI | Microsoft Learn

 

4.Here are some relevant example links that I hope will be helpful to you:

PowerBI-visuals-sampleBarChart/src/barChart.ts at main · microsoft/PowerBI-visuals-sampleBarChart · ...
Adding Interactions To Your Power BI Custom Visual
Solved: Visuals interactions - Microsoft Fabric Community

 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.