Reply
Regular Visitor
Posts: 20
Registered: ‎11-10-2017

How To Multiple Data Contexts?

I want to display two (or more) charts in the same visual, that interact of some sort.

For this, I need two (or more) data contexts (Dimension->Measure).

How can I define the contents of capabilities.json that I can define many dimensions and many measures AND inside my code I see all the data values in update().

At the moment only the values of the first dimension are visible:

 

My capabilities.json

{
    "dataRoles": [
        {
            "displayName": "Dimension",
            "name": "category",
            "kind": "Grouping"
        },
        {
            "displayName": "Measure Data",
            "name": "measure",
            "kind": "Measure"
        }
    ],
    "dataViewMappings": [
        {
            "categorical": {
                "categories": {
                    "for": {
                        "in": "category"
                    },
                    "dataReductionAlgorithm": {
                        "top": {}
                    }
                },
                "values": {
                    "select": [
                        {
                            "bind": {
                                "to": "measure"
                            }
                        }
                    ]
                }
            }
        }
    ],
    "objects": {...}
}

Is there any online resource/tutorial about multiple data contexts available?

Moderator
Posts: 1,610
Registered: ‎12-02-2016

Re: How To Multiple Data Contexts?

Hello @blumi78

 

Power BI returns all of values.

Have you checked the prototype object? I think the values of the second category is in the prototype.

You might access value of second category by this code below:

 

// options: VisualUpdateOptions

options.dataViews[0].categorical.categories[1].values

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Regular Visitor
Posts: 20
Registered: ‎11-10-2017

Re: How To Multiple Data Contexts?

@v-viig Thanks, I've found them! Do you have a solution for how to group them together? I want to make a (multi-)chart with N dimensions and M measures, where M >= N. So I need a mapping, which measure(s) relate to which dimension. I.e.:

 

dataviews[0].categorical.categories[0] => dataviews[0].categorical.values[0], dataviews[0].categorical.values[1]

dataviews[0].categorical.categories[1] => dataviews[0].categorical.values[2]

 

Do I need to make a custom GUI inside my extension for this or can this be done using the PowerBI sidebar somehow?

 

Thanks a lot!

Bastian

Moderator
Posts: 1,610
Registered: ‎12-02-2016

Re: How To Multiple Data Contexts?

I think there's no way to implement such behavior using Power BI sidebar.

In other words, you should implement your own GUI as did in Power KPI Matrix custom visual.

 

image.png

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Frequent Visitor
Posts: 2
Registered: ‎01-02-2019

Re: How To Multiple Data Contexts?

Hello,

How could we implement a custom GUI? we couldnt find any data related to it in the documentation and as per the below thread the code for Power KPI is private
https://community.powerbi.com/t5/Custom-Visuals-Development/Power-KPI-Matrix-source-code-in-github/t...
Thanks,

Moderator
Posts: 1,610
Registered: ‎12-02-2016

Re: How To Multiple Data Contexts?

You can use React or another library to build UI.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Frequent Visitor
Posts: 2
Registered: ‎01-02-2019

Re: How To Multiple Data Contexts?

Which UI Library to use is not the problem, the problem is how to inject this UI to Power BI custom visual.
Moderator
Posts: 1,610
Registered: ‎12-02-2016

Re: How To Multiple Data Contexts?

I suggest you start using our powerbi-visuals-tools@3.x.x.

 

It supports modern ES2015 import export and webpack. That means you can import almost any library and use it.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com