Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have created a new custum visual displaying multiple single values.
So I have this in my capabilities.json :
"dataRoles": [
{
"displayName": "Data",
"name": "category",
"kind": "Grouping"
}
],
...
"objects": {
"boolSettings": {
"displayName": "Bool settings",
"properties": {
"valueIfTrue": {
"displayName": "Value if true",
"type": {
"text": true
}
}
}
}
},
...
into the visual.ts I added
public enumerateObjectInstances(options: powerbi.EnumerateVisualObjectInstancesOptions): powerbi.VisualObjectInstanceEnumeration {
let objectName = options.objectName;
let properties: VisualObjectInstance[] = [];
switch (objectName) {
case "boolSettings":
if (this.viewModel) {
for (let dp of this.viewModel.data) {
debugger
if (typeof dp.value != "boolean")
continue
properties.push({
objectName,
displayName: "Value if true for :" + dp.title,
properties: {
valueIfTrue: dp.boolSetting.ValueIfTrue,
},
selector: dp.identity.getSelector()
})
}
}
break;
}
debugger
return properties;
}
and my data are fill like this :
for (let i = 0; i < view.categories.length; i++) {
let category = view.categories[i];
debugger
data.push({
title: category.source.displayName,
value: <string>category.values[0],
identity: host.createSelectionIdBuilder()
.withCategory(category, 0)
.createSelectionId(),
boolSetting: {
ValueIfFalse: "true"
}
})
}
and the settings are link with this :
for (let i = 0; i < data.length; i++) {
let objects = options.dataViews[0].categorical.categories[i].objects;
if (objects == undefined)
continue
let object = objects[0]
data[i].boolSetting.ValueIfTrue = dataViewObjects.getValue(object, {
objectName: "boolSettings",
propertyName: "valueIfTrue"
}, data[i].boolSetting.ValueIfTrue)
}
both methods are called one after the other.
With one category it's working fine, I can change the value. But with multiple categories all values are the same.
I looked in the debbuger and all identities seems to be the same.
here is the sample for two categories ("ifc" and "nwc" from the table "Files")
"key": "{\"and\":{\"l\":{\"comp\":{\"k\":0,\"l\":{\"col\":{\"s\":{\"e\":\"Files\"},\"r\":\"ifc\"}},\"r\":{\"const\":{\"t\":5,\"v\":true}}}},\"r\":{\"comp\":{\"k\":0,\"l\":{\"col\":{\"s\":{\"e\":\"Files\"},\"r\":\"nwc\"}},\"r\":{\"const\":{\"t\":5,\"v\":true}}}}}}"
how could I a different value for each category ?
thank you
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
3 | |
2 | |
2 | |
2 |