Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have a parent-child hierarchy table. I don't know in advance how many levels there are.
I need help with building a function that would flatten the levels.
I found this very helpful post:
https://pivotalbi.com/dynamically-flatten-a-parent-child-hierarchy-using-power-query-m/
It does everything. But it leaves "low" levels empty if the hierarchy is not longest.
So I basically ask for your help altering some M code to fill the empty values with the values from level above.
Here is a Power BI file
https://1drv.ms/u/s!AoP_9ampPIT7gdFtb4M-04m-1Z6JgQ?e=9EIk25
Thanks
Solved! Go to Solution.
I've solved it with a help of @LivioLanzo solution to this post.
https://community.powerbi.com/t5/Desktop/Parent-Child-Hierarchy-Highest-Parent-using-Power-Query-not...
It's dynamic, not fixed solution.
Hey how do you integrate/ define relationship between actual table data and this data in the bi visuals.
I had a data table which had parentid and childid, I used this and created the levels and added it to slicer now I want my visual to show me data related to only the selected childid or group id.Any idea on this
You are not just flattening the hierarchy - you are also forcibly converting it from ragged to fixed depth. Doing that with repetitions of values is generally frowned upon. While the function you mentioned could be modified that would include a second run to identify the maximum level of depth before you would then traverse the hierarchy. I don't think it is a good idea. What's the next step?
Note that Power Query producing variable output is asking for trouble. Your downstream processes (Power BI Meta data) will break.
I've solved it with a help of @LivioLanzo solution to this post.
https://community.powerbi.com/t5/Desktop/Parent-Child-Hierarchy-Highest-Parent-using-Power-Query-not...
It's dynamic, not fixed solution.
Hi @iBusinessBI , I'm looking for exactly this. Would you be so kind to share your PowerQuery / M-Code?
Here you can find the code:
https://community.fabric.microsoft.com/t5/Desktop/Parent-Child-Hierarchy-Highest-Parent-using-Power-...
User | Count |
---|---|
84 | |
77 | |
76 | |
43 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |