Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
absmiths
Regular Visitor

Accessing row data from table or matrix data view mapping.

I think this is a very basic question, but I am trying to process the data in a custom visual, and I can't figure out how to get it!  I have data roles defined thusly (mostly from guessing and looking at the sample bar chart and the schema):

 

"dataRoles": [

        {

            "displayName": "Measured Depth",

            "name": "measuredDepth",

            "kind": "Grouping"

        },

        {

            "displayName": "Is Planned",

            "name": "isPlanned",

            "kind": "Grouping"

        },

...

        {

            "displayName": "Dog Leg Severity",

            "name": "dogLegSeverity",

            "kind": "Grouping"

        }

 

And my data view mapping:

"matrix": {"rows": { "select": [

                    {"for": {"in": "measuredDepth"}},

                    {"for": {"in": "isPlanned"}},

...

                    {"for": {"in": "dogLegSeverity"}}

                ]

            }}

 

And lastly in my visual.ts update method:

var dv = options.dataViews;

var mtrxData = dv[0].matrix;

 

When I get to this point I am lost.  When I inspect the object I can't tell how to get data out.  All I want to do is iterate over the values for my inputs, meaning go row-by-row and access each input as a column.  What I really want is described as the table data view mapping, but I have 8 different required inputs and I didn't want to use just one big input role.  I know this requirement is odd, but my users really want a graphic (not an analytic) that graphs several data points, with no aggregation of any kind, in an extremely proprietary visual.

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Please use table data-mapping instead of matrix since you need to rows only and there's no need to generate a hierarchy.

 

Please use options.dataViews[0].table.rows to enumerate data-rows.

You can console log the data view object to understand its structure deeper.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

View solution in original post

3 REPLIES 3
v-viig
Community Champion
Community Champion

Please use table data-mapping instead of matrix since you need to rows only and there's no need to generate a hierarchy.

 

Please use options.dataViews[0].table.rows to enumerate data-rows.

You can console log the data view object to understand its structure deeper.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Thank you Ignat for your response!  I had tried that, but my mistake was doing it like this:

 

"table": {"rows": { "select": [

    {"for": {"in": ["measuredDepth","isPlanned"]}}

  ]

}}

 

I got an error that "in" cannot accept an array, so I wrongly concluded that it could only accept a single field.  This works nicely:

 

"table": {"rows": { "select": [

    {"for": {"in": "measuredDepth"}},

    {"for": {"in": "isPlanned"}}

  ]

}}

 

Thanks again!

Anonymous
Not applicable

Thanks for posting your solution, but could you also tell how it is possible to access the content of a special table cell (e.g. row=3, column=1) from the table in typescript?

 

Or can anybody else help with this?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.