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

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.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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