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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Custom visual selection: values in the selector are reset

Hi power bi community,

 

By following the tutorial for creation of barChart (https://github.com/microsoft/PowerBI-visuals-sampleBarChart), I have created two selectors A and B. If I filter the data only by selector "A", everything works good. But if click on value at selector "A" and then I select value at the selector "B", the selection in the filter "A" is reset (the array with the id of the selected elements becomes empty).

What could be the problem? 

1 REPLY 1
dm-p
Super User
Super User

As discussed privately, I haven't got much experience in this area, but I have had a quick look, and if you're using this tutorial, then I think that it's a case of enabling multiSelect on your select call.

You can see the specification for the select method in ISelectionManager here. Notice that there is an optional multiSelect property.

I've checked out the sample repo and can't get it to compile to verify, unfortunately, but I presume that your code would need to look as follows (based on the tutorial; change higlighted in red):

let selectionManager = this.selectionManager;

//This must be an anonymous function instead of a lambda because
//d3 uses 'this' as the reference to the element that was clicked.
bars.on('click', function(d) {
    selectionManager.select(d.selectionId, true).then((ids: ISelectionId[]) => {
        bars.attr({
            'fill-opacity': ids.length > 0 ? BarChart.Config.transparentOpacity : BarChart.Config.solidOpacity
        });

        d3.select(this).attr({
            'fill-opacity': BarChart.Config.solidOpacity
        });
    });

    (<Event>d3.event).stopPropagation();
});

There's also a great series on YouTube that works through a similar tutorial. It's for an older version of the SDK but a lot of the concepts still work. Here's a timestamped-link to where the above is illustrated, but the whole video is worth watching IMHO as it includes functionality such as dimming unselected data points.

Hopefully this should give you some options to explore. 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.