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
SriThiru
Helper I
Helper I

How to add Object dynamically in capabilities.json using enumerateObjectInstances method

How to dynamically add new objects in properties pane like the following screenshot (seen in donut chart), inside the enumerateObjectInstances method.

dynamicproperties.PNG

2 REPLIES 2
dm-p
Super User
Super User

Hi @SriThiru,

It's hard to provide a targeted answer without knowing your choice of data view mapping and view model, but the high-level approach to this is that:

  1. You create a 'template' property (or properties) within the object in capabilities.json for the property that you wish to bind to your data. This has the structure and typing that the main window needs to know about when the visual is initialised, as you cannot dynamically manipulate the capabilities post-initialisation.
  2. When you process your dataset, you assign a selector (reconciling the data point's grouping) to the attribute that you wish to bind to the properties pane. Selectors are not just used for interactivity and are the way of bridging your view model to the original data view that Power BI sends through.
  3. When enumerating your settings (enumerateObjectInstances), you use the knowledge of your data to push additional object instances that reference the template property (or properties) for each selector.

How to do this will very much depend on how you are intending to structure your data within the visual, and whether it is possible to retain the correct context against the data view that is sent to the visual by Power BI.

The easiest way to have a look and play with a working example would be to go through the sample bar chart visual and see what's being done to achieve the solution there. Specific points of interest in this codebase are:

  1. Template property
  2. How the selector is assigned when processing the view model (and how color is retrieved from properties)
  3. How the dynamic properties are added to the object when settings are enumerated

Here's an additional post where the author has a correct setup and shows these three in context (but the problem was actually something else).

Hopefully this should help you get a little further. 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)




Thanks @dm-p , for the detailed response, and the code reference, I'll try your suggestions.

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.