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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
feiyiding
Frequent Visitor

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!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

3 REPLIES 3
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!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors