In this post I consider two types of hierarchies
First table defines typical hierarchy of companies.
Usually, such hierarchy is used for financial reports to group key figures.
Most probably, we know number of hierarchy levels upfront, but not always.
Task: Expand hierarchy, automatically detect quantity of levels in resulting table using Power Query (Get & Transform) / Power BI
Stay close to scenario described in pattern: http://www.daxpatterns.com/parent-child-hierarchies/
Goal:
Second table defines substitution of products.
Case: sometimes we required to get sales history of all predecessor products and group result on Actual Product. There can be multiple substitutions, we never know amount.
Task: In this case we need to find the latest successor, Actual Product for each product in other words.
Goal: