Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!View all the Fabric Data Days sessions on demand. View schedule
Hi, I've made a Custom visual that Looks quite ok and has about 60 Format settings that a user can vary depending on their preference.
It all worked perfectly untill I saved a PBI file with this visual and opened it up again. All the settings were back to default. Any ideas on what I did wrong?
below is the general scheme of how my code looks like related to the settings:
...
interface Viewmodel {
...
settings: MSTASettings;
}
interface MSTASettings {
lines: {
show: boolean;
...
}
...
}
let defaultSettings: MSTASettings = {
lines: {
show: true,
...
}
...
}
export class Visual implements IVisual {
constructor(options: VisualConstructorOptions) {
this.mstaSettings = <MSTASettings>{};
...
}
public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration {
let objectEnumeration: VisualObjectInstance[] = [];
switch (options.objectName) {
case 'lines':
objectEnumeration.push({
objectName: objectName,
properties: {
show: this.mstaSettings.lines.show,
...
},
selector: {}
});
break;
...
return objectEnumeration
}
public update(options: VisualUpdateOptions) {
let viewModel = this.getViewModel(options);
let settings = this.mstaSettings = viewModel.settings;
...
}
private getViewModel(options: VisualUpdateOptions): Viewmodel {
let viewmodel: Viewmodel = {
...
settings:<MSTASettings>{},
...
};
viewmodel.settings = {
lines: {
show: getValue<boolean>(objects, 'lines', 'show', defaultSettings.lines.show),
...
},
...
}
...
return viewmodel;
}
function getValue<T>(objects: DataViewObjects, objectName: string, propertyName: string, defaultValue: T): T {
if (objects) {
let object = objects[objectName];
if (object) {
let property: T = <T>object[propertyName];
if (property !== undefined) {
return property;
}
}
}
return defaultValue;
}
}
Note: I didn't use the latest version as I started this project a couple of years ago and only now found the time to tweek it.
Note2: I tried getting rid of the line In the Constructor. My code still worked, but the issue remained the same.
Your visual resets to default because objects (the stored format settings in the DataView) aren’t being read correctly in getViewModel(). When Power BI reopens the file, it tries to restore settings from metadata.objects, but your code always falls back to defaultSettings.
Read objects properly
In update():
const dataView = options.dataViews && options.dataViews[0]; const objects = dataView?.metadata?.objects; let viewModel = this.getViewModel(options, objects); this.mstaSettings = viewModel.settings;
Pass objects into getViewModel().
Make sure names match capabilities.json
Object names like 'lines' and property names like 'show' must match exactly (case-sensitive).
Use correct selector
In enumerateObjectInstances:
selector: null
This ensures settings are stored globally, not per-data-point.
Don’t overwrite settings
Don’t reassign this.mstaSettings to defaults anywhere after reading from the model.
Change some visual settings → save PBIX → close → reopen.
If they persist, the issue’s resolved.
Essentially:
Ensure your visual reads metadata.objects, matches names from capabilities.json, and uses selector: null.
That’s what allows Power BI to restore formatting after reopening.
⭐Hope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
💡Found it helpful? Show some love with kudos 👍 as your support keeps our community thriving!
🚀Let’s keep building smarter, data-driven solutions together!🚀 [Explore More]
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!