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
absmiths
Regular Visitor

What determines the column order of a table data view mapping?

In my capabilities.json, I have data roles defined like this:

 

"dataRoles": [
	{"displayName": "Measured Depth", "name": "measuredDepth", "kind": "Grouping"},
	{"displayName": "Is Planned", "name": "isPlanned", "kind": "Grouping"},
	{"displayName": "Is Actual", "name": "isActual", "kind": "Grouping"},
	{"displayName": "Depth Above", "name": "depthAbove", "kind": "Grouping"},
	{"displayName": "Planned TVD", "name": "plannedTrueVerticalDepth", "kind": "Grouping"},
	{"displayName": "Depth Below", "name": "depthBelow", "kind": "Grouping"},
	{"displayName": "Actual TVD", "name": "actualTrueVerticalDepth", "kind": "Grouping"},
	{"displayName": "Dog Leg Severity", "name": "dogLegSeverity", "kind": "Grouping"}
]

And my data view mapping looks like this:

"dataViewMappings": [{
	"table": {"rows": { "select": [
		{"for": {"in": "measuredDepth"}},
		{"for": {"in": "isPlanned"}},
		{"for": {"in": "isActual"}},
		{"for": {"in": "depthAbove"}},
		{"for": {"in": "plannedTrueVerticalDepth"}},
		{"for": {"in": "depthBelow"}},
		{"for": {"in": "actualTrueVerticalDepth"}},
		{"for": {"in": "dogLegSeverity"}}
	]}}
}]

And yet, when I look at my row data in the javascript debugger, the columns do not come in that order (abbreviated):

{
	"0": {"roles": {"isActual": true}},
	"1": {"roles": {"isPlanned": true}},
	"2": {"roles": {"depthAbove": true}},
	"3": {"roles": {"plannedTrueVerticalDepth": true}},
	"4": {"roles": {"depthBelow": true}},
	"5": {"roles": {"actualTrueVerticalDepth": true}},
	"6": {"roles": {"dogLegSeverity": true}},
	"7": {"roles": {"measuredDepth": true}}
}

Is this normal, or did I set something up wrong?  Do I need to scan the columns and dynamically locate my data points on each refresh?  I sort of thought the data view mapping would handle that.

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Columns order depend on how you fill data-fields of your custom visual.

Custom visual must use roles property to detemine what column is.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

8 REPLIES 8
v-viig
Community Champion
Community Champion

Columns order depend on how you fill data-fields of your custom visual.

Custom visual must use roles property to detemine what column is.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Anonymous
Not applicable

@v-viig Can you give an example of how to use the 'roles' property to determine column? 

Hi @Anonymous,

We've recently discussed this here, and this helped out the person making the post. See if this works for you and we can discuss further as necessary.

Good luck!

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)




Anonymous
Not applicable

@dm-p 

Thanks for the link.   I am using a table this time. e.g. dataView.table...what's the syntax to get the corresponding columns if it is table?  Thanks.

 


@dm-p wrote:

Hi @Anonymous,

We've recently discussed this here, and this helped out the person making the post. See if this works for you and we can discuss further as necessary.

Good luck!

Daniel


 

Hi @Anonymous,

That post specifically deals with the dataView.table mapping, so not sure how much else I can provide without more targeted info. Might be better handling in a separate post that defines the issue more fully.

Failing that, I recently posted this on my website to walk through the mapping a bit further - not sure if it breaks it down more for you?

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)




Anonymous
Not applicable

@dm-p 

 

Ah Yes.  Sorry I was reading a wrong post.  Got it now!  Thanks!  Your function is brilliant!

Okay - not the answer I hoped for - but at least confirms my suspicion.  Perhaps this would be a good feature request since parsing column data and matching by name to the configured values will be a common activity (I would suspect).

v-viig
Community Champion
Community Champion

We'll consider this idea but it's pretty easy to implement by enumerating columns and checking role name.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

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.