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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ThibaudGD
Frequent Visitor

Dynamic settings on multiple categories

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

 

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.