Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
I'm working on a project to generate a custom visual that is a matrix with 2 groups (x, y) and 2 measures. Bascially it's a heatmap were the color value is measure2 while the display value is measure1. I've been able to get it working using the basic Value Data Role. But when I tried swap it out for XAxis, YAxis, Measure1, and Measure2 data roles I can't get it to work. Below is the capabilities.json file but I can't figurout the how to setup the dataViewMappings.
Here is an example of the data:
XAxis YAxis Measure1 Measure2
Product1 State1 300 105
Product2 State1 256 75
Product1 State2 50 15
{ "dataRoles": [ { "displayName": "Display Values", "kind": "Measure", "name": "measure1" }, { "displayName": "Heat Values", "kind": "Measure", "name": "measure2" }, { "displayName": "X Axis.", "kind": "Grouping", "name": "xAxis" }, { "displayName": "Y Axis.", "kind": "Grouping", "name": "yAxis" } ], "dataViewMappings": [ { "conditions": [ { "measure1": { "max": 1 }, "measure2": { "max": 1 }, "xAxis": { "max": 1 }, "yAxis": { "max": 1 } } ], "scriptResult": { "dataInput": { "table": { "rows": { "select": [ { "for": { "in": "measure1" } }, { "for": { "in": "measure2" } }, { "for": { "in": "xAxis" } }, { "for": { "in": "yAxis" } } ], "dataReductionAlgorithm": { "top": {} } } } }, "script": { "scriptProviderDefault": "R", "scriptOutputType": "html", "source": { "objectName": "rcv_script", "propertyName": "source" }, "provider": { "objectName": "rcv_script", "propertyName": "provider" } } } } ], "objects": { "rcv_script": { "properties": { "provider": { "type": { "text": true } }, "source": { "type": { "scripting": { "source": true } } } } } }, "suppressDefaultTitle": true }
Are you going to use it with R-script?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Yes I'm using an R script and Plotly. One thing I failed to mention in my previous post is that I put a Stop(<dataRole>) in to see what values are being used. For the measures I get the correct values, but for the groups I'm getting numbers and not the actual text values.
As far as I know, Power BI might return numbers for grouping if the field contains numbers.
Does this fact affect your code somehow?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Unfortunatly no because the data in those axis columns is text not numbers.
If I change the capabilties.json file back to it's original form:
{ "dataRoles": [ { "displayName": "Values", "kind": "GroupingOrMeasure", "name": "Values" } ], "dataViewMappings": [ { "scriptResult": { "dataInput": { "table": { "rows": { "select": [ { "for": { "in": "Values" } } ], "dataReductionAlgorithm": { "top": {} } } } }, "script": { "scriptProviderDefault": "R", "scriptOutputType": "html", "source": { "objectName": "rcv_script", "propertyName": "source" }, "provider": { "objectName": "rcv_script", "propertyName": "provider" } } } } ], "objects": { "rcv_script": { "properties": { "provider": { "type": { "text": true } }, "source": { "type": { "scripting": { "source": true } } } } } }, "suppressDefaultTitle": true }
I can then access in my r script Values$[columnName], but the columnNames need to be hard coded. I'm basically trying to genericize this visual so I can use it with other data.
Is there a way of seeing table definition? I tried to view it through dataViews[0] but that didn't seem to be available in R. Also is there a way to debug the R script with the data being sent it?
Could you please send an email to pbicvsupport@microsoft.com? Or share your email?
We'd like to include our R-script engineer to assist you with this issue.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Was this ever resolved? I'm going through the same process, and I'm finding myself to be lost in the capabilities options for the different dataviewmappings.
Thanks!
I'm working on a project to generate a custom visual that is a matrix with 2 groups (x, y) and 2 measures. Bascially it's a heatmap were the color value is measure2 while the display value is measure1. I've been able to get it working using the basic Value Data Role. But when I tried swap it out for XAxis, YAxis, Measure1, and Measure2 data roles I can't get it to work. Below is the capabilities.json file but I can't figurout the how to setup the dataViewMappings.
Here is an example of the data:
XAxis YAxis Measure1 Measure2
Product1 State1 300 105
Product2 State1 256 75
Product1 State2 50 15
{ "dataRoles": [ { "displayName": "Display Values", "kind": "Measure", "name": "measure1" }, { "displayName": "Heat Values", "kind": "Measure", "name": "measure2" }, { "displayName": "X Axis.", "kind": "Grouping", "name": "xAxis" }, { "displayName": "Y Axis.", "kind": "Grouping", "name": "yAxis" } ], "dataViewMappings": [ { "conditions": [ { "measure1": { "max": 1 }, "measure2": { "max": 1 }, "xAxis": { "max": 1 }, "yAxis": { "max": 1 } } ], "scriptResult": { "dataInput": { "table": { "rows": { "select": [ { "for": { "in": "measure1" } }, { "for": { "in": "measure2" } }, { "for": { "in": "xAxis" } }, { "for": { "in": "yAxis" } } ], "dataReductionAlgorithm": { "top": {} } } } }, "script": { "scriptProviderDefault": "R", "scriptOutputType": "html", "source": { "objectName": "rcv_script", "propertyName": "source" }, "provider": { "objectName": "rcv_script", "propertyName": "provider" } } } } ], "objects": { "rcv_script": { "properties": { "provider": { "type": { "text": true } }, "source": { "type": { "scripting": { "source": true } } } } } }, "suppressDefaultTitle": true }
Looks like it's a duplicate of this one.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
User | Count |
---|---|
15 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
18 | |
11 | |
5 | |
4 | |
3 |