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
Anonymous
Not applicable

Adding interactivity into custom visual using table dataviewmapping

I'm working on adding interactivity into my custom visual. And I'm trying the code from https://docs.microsoft.com/en-us/power-bi/developer/visuals/selection-api#select-datapoints-to-slice...

However, I don't understand what is "rowDiv". Can someone explain this?

feiyiding_0-1631709235702.png

 

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

I've never looked at this particular section of the selection ID doc in great detail, but the sample code is certainly not going to work completely as-is and this is very unfortunate, as selection handling is one of the more tricky bits to get right.

rowDiv is not scoped anywhere, so this line of code is not valid in context. I would expect rowDiv to be declared and assigned above that line, as presumably it will be different for each iteration of the forEach loop and appends the correct data.

As it is an incomplete fragment of code, I couldn't presume to know how to make it work fully and the only useful part of that code snippet is that bit that shows the difference on how to create the selection ID using .withTable() vs. the other data view mappings. The selection ID is not assigned to any event listener or persisted elsewhere either, so this potentially causes further confusion.

If you're looking for some assistance, it might be better if you can share your code, or the section that works with your data view and we can see if we can help adapt this for you.

If you're not able to share, or it is impractical, the example for the categorical mapping in the doc page is a bit more complete and could be adapted, with considerations for the slightly different structure of the table data view mapping and how to use .withTable() rather than .withCategory() / .withSeries() / .withMeasure().

Regards,

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)




View solution in original post

4 REPLIES 4
dm-p
Super User
Super User

I've never looked at this particular section of the selection ID doc in great detail, but the sample code is certainly not going to work completely as-is and this is very unfortunate, as selection handling is one of the more tricky bits to get right.

rowDiv is not scoped anywhere, so this line of code is not valid in context. I would expect rowDiv to be declared and assigned above that line, as presumably it will be different for each iteration of the forEach loop and appends the correct data.

As it is an incomplete fragment of code, I couldn't presume to know how to make it work fully and the only useful part of that code snippet is that bit that shows the difference on how to create the selection ID using .withTable() vs. the other data view mappings. The selection ID is not assigned to any event listener or persisted elsewhere either, so this potentially causes further confusion.

If you're looking for some assistance, it might be better if you can share your code, or the section that works with your data view and we can see if we can help adapt this for you.

If you're not able to share, or it is impractical, the example for the categorical mapping in the doc page is a bit more complete and could be adapted, with considerations for the slightly different structure of the table data view mapping and how to use .withTable() rather than .withCategory() / .withSeries() / .withMeasure().

Regards,

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)




Anonymous
Not applicable

https://community.fabric.microsoft.com/t5/Developer/adding-interaction-to-custom-visual/td-p/3990283
please help me with this post. i am facing same issue . please share any sample visual.ts file

Anonymous
Not applicable

Thank you for the reply. I have figured it out.

Hello, is it possible for you to share the source code because I am struggling with the same thing?

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.