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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.