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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
jeffiefgf
Frequent Visitor

DataView tree documentation

I am creating a custom tree visual that's similar to a decomposition tree but I'm not sure which dataViewMapping is best for creating trees. When I was trying things out with Categorical data mapping, I found out that there is a tree data mapping which is not in Microsoft's documentation (https://docs.microsoft.com/en-us/power-bi/developer/visuals/dataview-mappings😞 

jeffiefgf_0-1648667456199.png

 

I tried looking further for its documentations but I'm not able to find anything. If anyone can show me how tree data mapping works or has any suggestions about which data mapping works best with trees, it would be greatly appreciated. Thanks in advance.

3 REPLIES 3
dm-p
Super User
Super User

Hi @jeffiefgf,

Not sure why that's there (IIRC it has been for as long as I've been developing), but the following valid data view mappings in the API are as documented:

  • single
  • categorical
  • table
  • matrix
  • scriptResult (for R visuals)

This can be confirmed by checking the schema defs for the API.

Your best bet might be to use matrix, as this supports selections for each level of a hierarchy and has had a lot more investment in the last few API releases (particularly with fetching/lazy-loading more data from the model programmatically, although I haven't personally used it recently).

Categorical has very simple support for hierarchies (either drill or expand, and you only have info about the currently displayed level), whereas matrix uses a recursive mapping that should allow you to traverse the whole dataset without user interaction.

A good place to start might be to look at the source for Hierarchy Slicer (by Jan Pieter Posthuma), which uses this mapping and has options to filter out null levels in a dataset without modelling.

Hopefully some of this can help you get started. 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)




Thank you @dm-p for your reply, matrix does look like the right place to start but if I use matrix to map data, is it possible to get the values at each level, not just the leaf nodes?

 

What I mean by that is if you look at the data structure of a matrix:

jeffiefgf_0-1648746897238.png

we only get the "values" for the leaf node Grand child1 but not Parent1 and Child1. For the tree structure I am creating, I'll need the values for all nodes, so that it can look like something similar to this:

jeffiefgf_1-1648747234837.png

Again, thank you in advance, I am still new to this so I really appreciate your help!

Hi @jeffiefgf - I've never worked with more than 2 levels, but if this is how it is implemented for more than that, then you may need to 'collect' the node values on the way through and add them to your viewmodel before they are 'lost', rather than re-processing the data portion of your viewmodel entirely for each update?

Failing that, someone else with more experience with the matrix mapping may be able to weigh-in.





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)




Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.