cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bobmarley
Frequent Visitor

Dynamically generate enumeration object

Hi there,

 

I am working on custom visual and I want to generate values of enumeration object dynamiclly bassed on measures name. below is my object structure in capabilities.json file.

 

"formatSettings": {
            "displayName": "Format Measures",
            "properties": {
                "measureLists":{
                    "displayName": "Measures List",
                    "type": {
                        "enumeration": []
                    }
                }
            }
        }

I tried adding dynamic values in enumeration object with below code but it is not working.

public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] 
        | VisualObjectInstanceEnumerationObject {
            let settings: VisualObjectInstance[] = (VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options) as VisualObjectInstanceEnumerationObject).instances;
            console.log(settings);
            switch(options.objectName){
                case "formatSettings":{
                    settings.push({
                        objectName: options.objectName,
                        properties:{
                            measureList: ['test', 'test2']
                        },
                        selector: null
                    });
                }
            }
            return settings;
        }

I am unable to find proper documentation regarding how to achive this. If someone has successfully implemented this, please share the solution with me.

 

Thank you. 

5 REPLIES 5
v-viig
Community Champion
Community Champion

Dynamic enumerations are not supported yet.

We'll update this thread once it's supported (not ETA so far).

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

a10k
Frequent Visitor

Is there any update on this? I see this works fine on the inbuilt visuals.. This feature would be great to have, especially when trying to change properties per element. Is there any workaround you would recommend currently?

v-viig
Community Champion
Community Champion

There's no workaround for this issue. It's on backlog but there's no ETA because it will require a very redesign in how Power BI handles capabilities.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

scriptpup
Frequent Visitor

If this feature isn't supported and there's no ETA, why is there a tutorial document for it?

https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/DataBoundObjects.md

Hi @scriptpup - this is not quite the same thing. You have always been able to generate properties at the top-level using the technique linked in the example.

The question is referring to dynamically changing the values in properties with dropdown values (enumerations). A use case for this is where you might have multiple measures in your visual and you want to have dynamic selection of properties, for example, in the the core matrix visual's Field formatting menu, e.g.:

image.png

Each entry has its own distinct set of properties that show/hide based on the selected measure.

These have to be manualy defined in custom visuals and cannot work dynamically like the above.

A lot of us would really like this feature, and have used the article you've linked as a (somewhat undesirable) workaround in some cases.

I hope that this clarifies the question OP is asking.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors