Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
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😞
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.
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:
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
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:
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:
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.
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)
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.