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
RichardL
Microsoft Employee
Microsoft Employee

How to define dataViewMappings for multiple tables?

Let's say I'm importing two separate tables of data into my custom visual, and these two tables have different column count and row count.  Is is even possible to declare dataRoles and dataViewMappings for these two tables?  I basically want to read all data in from both tables.

 

I tried the lines of code below in my capabilities.json, but Power BI Desktop just gave me the "Unexpected Error" dialog box:

 

"dataRoles": [
   {
      "displayName": "Foo",
      "name": "foo",
      "kind": 2
   },
   {
      "displayName": "Bar",
      "name": "bar",
      "kind": 2
   },
   {
      "displayName": "X",
      "name": "x",
      "kind": 2
   },
   {
      "displayName": "Y",
      "name": "y",
      "kind": 2
   },
   {
      "displayName": "Data",
      "name": "data",
      "kind": 2
    }
],

 

"dataViewMappings": [
   {
      "conditions": [
           { "foo": { "max": 1 }, "bar": { "max": 1 } }
      ],
      "table": {
          "rows": {
             "select": [
                 { "for": { "in": "foo" } },
                 { "for": { "in": "bar" } }
             ],
             "dataReductionAlgorithm": { "top": { "count": 16000 } }
         },
         "rowCount": { "preferred": { "min": 2, "max": 16000 }, "supported": { "min": 1, "max": 20000 } }
      }
   },
   {
      "conditions": [
         { "x": { "max": 1 }, "y": { "max": 1 }, "data": { "max": 1 } }
      ],
      "table": {
         "rows": {
             "select": [
                 { "for": { "in": "x" } },
                 { "for": { "in": "y" } },
                 { "for": { "in": "data" } }
             ],
             "dataReductionAlgorithm": { "sample": { "count": 30000 } }
         },
         "rowCount": { "preferred": { "min": 2, "max": 30000 }, "supported": { "min": 1, "max": 64000 } }
      }
   }
],

 

Any ideas?  Thanks.

14 REPLIES 14
Anonymous
Not applicable

Has there been any progress on this issue in the 5 years since the original post?
I've tried adding multiple dataViews with no luck

Hi @Anonymous - no, it still isn't supported. I ask the team quite frequently for this, but there are no plans to address it (presumably because core visuals don't have these capabilities either and custom visuals APIs would need to build upon this).





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

Proud to be a Super User!


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




Hi
It's such a shame! So much potential lost. I suggested three workarounds of that problem to my client, but they were unhappy with them. We'll see if the project starts at all. Without this limitation, over 100 users would benefit greatly from the custom visual.

v-chuncz-msft
Community Support
Community Support

@RichardL,

 

As mentioned at https://github.com/Microsoft/PowerBI-visuals/blob/master/Capabilities/DataViewMappings.md, Each valid mapping will produce a DataView, but currently we only support performing one query per visual so in most situations you will only get one DataView. However, you can provide multiple data mappings with different conditions which allow. From my point of view, it is not supported yet.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft

 

So it appears that I only get one DataView, as you mentioned.  I tried printing out the dataViews in the update(), and dataViews[0] was the only valid one.  The rest were null.

@RichardL,

 

Now the default API version for new visuals has been changed to 1.2.0. You may check the capabilities JSON schema at https://github.com/Microsoft/PowerBI-visuals-tools/blob/master/templates/visuals/.api/v1.2.0/schema..... For tips about debugging your custom visual, see the debugging guide. Besides, you could also reach out for help at GitHub.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft - Version 1.2.0 actually broke my table.  One of the columns in the table contains a text string in each row as data (a hyperlink to an image), and Power Bi Desktop now shows that column as a count instead of individual strings.   There isn't an option to make it not a count.  The only options in that field are:  Remove field, Quick Calc, Count (Distinct), and Count.  On the Modeling tab, Default Summarization is set to "Do Not Summarize".  Any insights here?  Thanks.  

@RichardL,

 

There are still a few limitations to using the PowerBI command line tools. Just keep a close eye on its progress.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft - switching the dataRoles kind from "Measure" to "GroupingOrMeasure" in capabilities.json fixes my column count issue.

@RichardL,

 

Thanks for sharing the information. We can see that the kind property has been changed.

        "dataRole.kind": {
            "type": "string",
            "enum": [
                "Grouping",
                "Measure",
                "GroupingOrMeasure"
            ]
        },
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft - Yes, the kind property has been changed in 1.2.0.  We can no longer use a number to indicate a kind since it is now a string.

@v-chuncz-msft - Thanks.  I took a look at v 1.2.0 but still didn't see anything that would allow me to import multiple tables.  I only noticed the newly added "drilldown" property and "scriptResult" dataViewMapping.

 

Went ahead and updated to version 1.2.0.  Power BI Desktop still crashed and burned when I tried to import in two tables (dataViews has a length of 0).

Riaon
Microsoft Employee
Microsoft Employee

You mean that your orignal custom view works but it reported error after adding the following codes. Right? Maybe you can share the original code and updated code to do more diagnosis.

RichardL
Microsoft Employee
Microsoft Employee

@Riaon

 

Yep, my original custom view works and produces one dataView.  Original code is shown below:

 

"dataRoles": [
   {
      "displayName": "Foo",
      "name": "foo",
      "kind": 2
   },
   {
      "displayName": "Bar",
      "name": "bar",
      "kind": 2
   }
],

 

"dataViewMappings": [
   {
      "conditions": [
           { "foo": { "max": 1 }, "bar": { "max": 1 } }
      ],
      "table": {
          "rows": {
             "select": [
                 { "for": { "in": "foo" } },
                 { "for": { "in": "bar" } }
             ],
             "dataReductionAlgorithm": { "top": { "count": 16000 } }
         },
         "rowCount": { "preferred": { "min": 2, "max": 16000 }, "supported": { "min": 1, "max": 20000 } }
      }
   }
]

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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