Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Dear Community,
I am currently having an issue with compiling a custom visual. I have intorduced a custom object (myCustomObj) with a boolean property (myprop). I am following the tutorial here: https://blogs.msdn.microsoft.com/tsmatsuz/2016/09/27/power-bi-custom-visuals-programming/
I am getting the error "TYPESCRIPT /src/visual.ts : (44,13) Type 'string | number | boolean | Date | Fill | FillRule | ISemanticFilter | DefaultValueDefinition | I...' is not assignable to type 'boo
lean'.
Type 'string' is not assignable to type 'boolean'."
I have no idea what the issue could be, it says there is an error with the following line in my update function:
this.myVisualProp = options.dataViews[0].metadata.objects["myCustomObj"]["myprop"];
Yet when I put in a debugger and tried typeof(options.dataViews[0].metadata.objects["myCustomObj"]["myprop"]) in the console it returned "boolean". If I am doing something wrong please let me know, my full code is below: visual.ts, capabilities.json
module powerbi.extensibility.visual { export class Visual implements IVisual { private target: HTMLElement; private myVisualProp: boolean; constructor(options: VisualConstructorOptions) { var captionArea = document.createElement("div"); captionArea.innerHTML = "This is a test chart"; options.element.appendChild(captionArea); this.target = document.createElement("div"); options.element.appendChild(this.target); this.myVisualProp = false; } public update(options: VisualUpdateOptions) { this.myVisualProp = options.dataViews[0].metadata.objects["myCustomObj"]["myprop"]; this.target.innerHTML = "Custom Prop is " + this.myVisualProp; } public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstanceEnumeration { let objectName = options.objectName; let objectEnumeration: VisualObjectInstance[] = []; switch (objectName) { case 'myCustomObj': objectEnumeration.push({ objectName: objectName, properties: { myprop: this.myVisualProp, }, selector: null }); break; }; return objectEnumeration; } public destroy(): void { //TODO: perform any cleanup tasks here } } }
{ "dataRoles": [ { "displayName": "Category Data", "name": "category", "kind": "Grouping" }, { "displayName": "Measure Data", "name": "measure", "kind": "Measure" }, { "displayName": "Grouping", "name": "myGroup", "kind": "Grouping" } ], "dataViewMappings": [ { "table": { "rows": { "select": [ {"for": {"in": "myCategory"}}, {"for": {"in": "measure"}} ] } } } ], "objects": { "myCustomObj": { "displayName": "Test Object", "properties": { "myprop": { "displayName": "Test Property", "type": { "bool": true } } } } } }
Solved! Go to Solution.
You may add Type assertions to workaround this issue.
You may add Type assertions to workaround this issue.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
6 | |
4 | |
2 | |
2 |
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
3 |