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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
abed_azazi
Frequent Visitor

Hierarchy tree for bill of material with matrix and nodes

Hi All 

I am new in DAX and understand that I can get the hierarchy using the PATH; which can accumulate the count of the child components in the parent record. the same table would have the bill of material for more than 10 different products using similar components in different levels.

ChildParentDescriptionProcess GroupHierarchy PATHLevelStatusProduct

AA60 Product1AssemblyAA600PendingProduct 1
AA61AA601AssemblyAA60|AA611PendingProduct 1
AA62AA602AssemblyAA60|AA621ReleasedProduct 1
AA63AA613AssemblyAA60|AA61|AA632ReleasedProduct 1
AA64AA614FabricationAA60|AA61|AA642ReleasedProduct 1
AA65AA635AssemblyAA60|AA61|AA63|AA653ReleasedProduct 1
AA66AA636FabricationAA60|AA61|AA63|AA663PendingProduct 1
AA67AA647FabricationAA60|AA61|AA64|AA673ReleasedProduct 1
AA68AA628FabricationAA60|AA62|AA682ReleasedProduct 1
AA69AA659AssemblyAA60|AA61|AA63|AA65|AA694ReleasedProduct 1
AA70AA6510AssemblyAA60|AA61|AA63|AA65|AA704ReleasedProduct 1
AA71AA6911AssemblyAA60|AA61|AA63|AA65|AA69|AA715ReleasedProduct 1
AA72AA6912AssemblyAA60|AA61|AA63|AA65|AA69|AA725ReleasedProduct 1
AA73AA7213PartAA60|AA61|AA63|AA65|AA69|AA72|AA736PendingProduct 1
AA74AA7214PartAA60|AA61|AA63|AA65|AA69|AA72|AA746ReleasedProduct 1
AA75AA6315AssemblyAA60|AA61|AA63|AA753ReleasedProduct 1
AA76AA7516PartAA60|AA61|AA63|AA75|AA764PendingProduct 1
AA77AA6517PartAA60|AA61|AA63|AA65|AA774ReleasedProduct 1
AA78 Product2AssemblyAA780PendingProduct 2
AA79AA60112AssemblyAA78|AA791PendingProduct 2
AA80AA60122AssemblyAA78|AA79|AA802ReleasedProduct 2
AA81AA611221AssemblyAA78|AA79|AA80|AA813ReleasedProduct 2
AA82AA6112212FabricationAA78|AA79|AA80|AA823ReleasedProduct 2
AA83AA638976AssemblyAA78|AA79|AA80|AA833PendingProduct 2
AA84AA613AssemblyAA78|AA79|AA80|AA833ReleasedProduct 2
AA85AA614FabricationAA78|AA79|AA80|AA833ReleasedProduct 2
AA86AA635AssemblyAA78|AA79|AA80|AA833ReleasedProduct 2
AA87AA636FabricationAA78|AA79|AA80|AA833PendingProduct 2

 

The need is to build a multi-level hierarchy visual for the bill of material by filtering the parent and accumulating the child components using a DAX measure without depending on the aggregation in the matrix visual, this is because I need to filter each matrix with a specific index of a particular parent to ensure the flexibility of the populated data based on the selected product.

 

AAACCC     PENDING    (Should automatically gets generated based on level 1 of the selected product1)                         

Process Group

Pending

Released

Assembly

0

7

Fabrication

0

3

Part

2

2

 

DDFFSSS    RELEASED     (Should automatically gets generated based on level 1 of the selected product1)                         

Process Group

Pending

Released

Assembly

0

0

Fabrication

0

1

Part

0

0

       

UUYYYRD      (Should automatically gets generated based on level 2 of the selected product1)                         

Process Group

Pending

Released

Assembly

0

6

Fabrication

1

0

Part

2

2

 

The same way should be generated for all the parent components of the levels from 1 to 4 accomulating the subsequent levels.

I tried using the custom hierarchy tree from xViz but it is very expensive and the trial one does not support matrix as tree nodes.

 

Anyone would help on this requirement ?

I have an idea of calculating the count of child components by using the Hierarchy PATH. Would this work ? if yes please write me the DAX.  



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @abed_azazi ,

 

Sorry for the late reply.

If your visual involves dynamic filtering of results, you could try replacing the all() function with allselected().

The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. This function can be used to obtain visual totals in queries.

Refer to:

ALLSELECTED function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @abed_azazi ,

 

Sorry for the late reply.

If your visual involves dynamic filtering of results, you could try replacing the all() function with allselected().

The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. This function can be used to obtain visual totals in queries.

Refer to:

ALLSELECTED function (DAX) - DAX | Microsoft Learn

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks for the reply from lbendlin , please allow me to provide another insight: 
Hi  @abed_azazi ,

 

Here are the steps you can follow:

1. Create two slicer tables that are not connected to the main table.

Description_Table =
DISTINCT('Table'[Description])

vyangliumsft_0-1733296370407.png

Status_Table =
DISTINCT('Table'[Status])

vyangliumsft_1-1733296370409.png

2. Create measure.

Pending =
var _selectdescription=SELECTEDVALUE('Description_Table'[Description])
var _selectstatus=SELECTEDVALUE('Status_Table'[Status])
var _child=
MAXX(FILTER(ALL('Table'),'Table'[Description]=_selectdescription&&'Table'[Status]=_selectstatus),[Child])
var _level=
MAXX(FILTER(ALL('Table'),'Table'[Description]=_selectdescription&&'Table'[Status]=_selectstatus),[Level])
var _count=
COUNTX(
    FILTER(ALL('Table'),
    [Process Group]=MAX('Table'[Process Group])&&
    CONTAINSSTRING(
    [Hierarchy PATH],_child)=TRUE()&&[Status]="Pending"&&
     [Level]>_level),[Child])
RETURN
IF(
    _count=BLANK(),0,_count)
Released =
var _selectdescription=SELECTEDVALUE('Description_Table'[Description])
var _selectstatus=SELECTEDVALUE('Status_Table'[Status])
var _child=
MAXX(FILTER(ALL('Table'),'Table'[Description]=_selectdescription&&'Table'[Status]=_selectstatus),[Child])
var _level=
MAXX(FILTER(ALL('Table'),'Table'[Description]=_selectdescription&&'Table'[Status]=_selectstatus),[Level])
var _count=
COUNTX(
    FILTER(ALL('Table'),
    [Process Group]=MAX('Table'[Process Group])&&
    CONTAINSSTRING(
    [Hierarchy PATH],_child)=TRUE()&&[Status]="Released"&&
     [Level]>_level),[Child])
RETURN
IF(
    _count=BLANK(),0,_count)

3. Result:

vyangliumsft_2-1733296476031.png

There's a question:

When the selection is “AAACCC and PENDING”, I found that the data in which [Process Group]=Fabrication&&[Status]=Pending&&[level] is less than the selected data's corresponding [level] is one.

vyangliumsft_3-1733297080493.png

When the selection is “AAACCC and PENDING”, I found that the data in which [Process Group]=Fabrication&&[Status]= Released &&[level] is less than the selected data's corresponding [level] is two.

vyangliumsft_4-1733297080499.png

So the result is derived as:

vyangliumsft_5-1733297099095.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thank you Liu,

I think you missed that we need to have an initial filter of the product as the table has the bill of material for more than 10 different products using the same components.

I believe we should not always use the ALL filter in the measures ! can you help here ?

abed_azazi
Frequent Visitor

The data changes daily, and each engineer will release the design of a few components.

 

lbendlin
Super User
Super User

Why do you need a measure?  This data is immutable.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.