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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
danieleperilli
Kudo Commander
Kudo Commander

host.persistProperties with data bound properties

Hi everyone,

 

I have 2 different problems with the host.persistProperties method with data bound properties. I'm perfectly able to use it with static properties.

 

1. When the property is bound to a measure I use this syntax:

host.persistProperties({
    merge: [
        {
            objectName: "dataPoint",
            properties: {
                "color": "#000000"
            },
            selector: {
                metadata: "Sales.Sales Cost"
            }
        }
    ]
});

In this case the property "color" is stored but I need to call an additional update to see the property in the dataview - in fact the update that comes immediately after the persistProperties call doesn't contain the updated color. Workaround: after calling the host.refreshHostData method the dataview is correctly updated. Is it something that can be fixed? I would avoid using the workaround if possible.

 

2. When the property is bound to a category, instead, I use this syntax:

host.persistProperties({
    merge: [
        {
            objectName: "dataPoint",
            properties: {
                "color": "#000000"
            },
            selector: {
                data: [ { "identityIndex": 0 } ]
            },
            // containerIdx: 0 // I also tried this...
        }
    ]
});

Unfortunately, it doesn't seem to work. Please note that the selector in the sample has been created with the selectionIdBuilder.withCategory... Am I missing something or is there an issue? 

 

Thanks,

Daniele

4 REPLIES 4
MartinRKrupa
Regular Visitor

Hi, I'm having the very same issue here. Have you find a solution in the meanwhile? Thanks.

danieleperilli
Kudo Commander
Kudo Commander

Anyone can help us?

danieleperilli
Kudo Commander
Kudo Commander

Hi Rico,

I know how the method works, thanks, since I use it in several projects from 6 years 😄

I'm talking about using the method with a not null selector, which is when the issue raises.

Can you provide a working example of using the persistProperties method with a selector pointing to a category bound property? E.g. You have a categorical data mapping and a property that must be saved on categories values like a color for each category.

Thanks

Anonymous
Not applicable

Hi @danieleperilli ,

 

From the offical blog: VisualConstructorOptions

  • persistProperties, allows users to create persistent settings and save them along with the visual definition, so they're available on the next reload

You can look for an example in powerbi-visuals-sankey custom visual, where it is used to store various properties.

powerbi-visuals-sankey

A rough example for your case:

options.host.persistProperties({
            VisualObjectInstance = {
            objectName: "filterSetting",
            selector: undefined, 
            properties: {
                filter: "xyz"
            }
        };
     });

After triggering the persistProperties function, the visual triggers an update, populating the VisualUpdateOptions' options.dataViews.metadata.objects with the persisted property. Note, that you have to define your property in the capabilities.json beforehand.

 

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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