cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
blumi78 Helper I
Helper I

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?

7 REPLIES 7
v-viig Community Champion
Community Champion

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

blumi78 Helper I
Helper I

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

v-viig Community Champion
Community Champion

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

GhadaElshamy
Frequent Visitor

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,

v-viig Community Champion
Community Champion

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

GhadaElshamy
Frequent Visitor

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.
v-viig Community Champion
Community Champion

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

 

 

Helpful resources

Announcements
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.