Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

How do I persist a dynamic number of properties in a custom visual?

Hi developers,


I am trying to work out if (and how) I can persist a previously unknown number of properties in my custom visual. I have successfully persisted a single, static property so far. Now, I would like to persist an item of data per value, not knowing the number of values in advance. Can that be done? I'm adding some example code here that has no practical purpose, so please bear with me.


In order to achieve this, I want to add an object to the capabilities.json like this:



 "misc": {
            "displayName": "Miscellaneous",
            "displayNameKey": "Visual_Persistent_Data",
            "properties": {
                "myPeristedStaticData": {
                    "type": {
                        "text": true
                "myPersistedDynamicData": {
                    "type": {
                        "text": true



Naturally I will not be displaying these in the property pane. Instead, I will be replacing the "myPersistedDynamicData" with the properties I want to persist.


To my settings.ts I add the following:



export class VisualSettings extends DataViewObjectsParser {
      public dataPoint: dataPointSettings = new dataPointSettings();
      public misc: miscSettings = new miscSettings();

    export class dataPointSettings {
      public defaultColor: string = "";
      public showAllDataPoints: boolean = true;
      public fill: string = "";
      public fillRule: string = "";
      public fontSize: number = 12;

     export class miscSettings {
       public myPersistedStaticData: string = "";
       public myPersistedDynamicData: string[] = [];




My aim is to populate the myPersistedDynamicData array with one item per value during the call to enumerateObjectInstances() by adding instances to the instanceEnumeration and then calling persisProperties(). I thought of something like this, but the dynamic part is not persisted:



   private persist(noOfValues:number) {
      for (i=0; i<noOfValues; i++) {  
        let propertyName = "property"+i.toString();
        let objects: powerbi.VisualObjectInstancesToPersist = {
            merge: [
                    objectName: "misc",
                    selector: undefined,
                    properties: {
                        "myStaticPersistedData" : this.myStaticData,
                        propertyName : this.myDynamicData[i] 



How can I dynamically add properties and persist them?


Thanks for reading this far!


Community Support
Community Support

Hi @WouterBo ,


Objects and properties of Power BI visuals - Power BI | Microsoft Docs

Hope the official documentation can help you.


Best regards,
Lionel Chen

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

It cannot Lionel, but hope springs eternal I suppose.

Helpful resources

PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!


Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors