Forum Discussion
Generate Recursive Bill of Material
- Anonymous1 year ago
Thanks for lbendlin's concern about this issue.
Hi, tjgagner
I am glad to help you.
Perhaps you can refer to my DAX to create a calculation table:
FlattenedBOM = UNION ( SELECTCOLUMNS ( FILTER ( 'OriginalTable', 'OriginalTable'[BOM Material] IN SELECTCOLUMNS ( 'OriginalTable', 'OriginalTable'[Component Material] ) = FALSE () ), "BOM Material", [BOM Material], "Component Material", [Component Material], "Level", 1 ), ADDCOLUMNS ( SELECTCOLUMNS ( FILTER ( CROSSJOIN ( 'OriginalTable', SELECTCOLUMNS ( 'OriginalTable', "BOM Material2", 'OriginalTable'[BOM Material], "Component Material2", 'OriginalTable'[Component Material] ) ), [BOM Material2] = [Component Material] ), [BOM Material], "Component Material", [Component Material2] ), "Level", 2 ) )Result:
I have attached the pbix for this example below, I hope it helps!I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for lbendlin's concern about this issue.
Hi, tjgagner
I am glad to help you.
Perhaps you can refer to my DAX to create a calculation table:
FlattenedBOM =
UNION (
SELECTCOLUMNS (
FILTER (
'OriginalTable',
'OriginalTable'[BOM Material]
IN SELECTCOLUMNS ( 'OriginalTable', 'OriginalTable'[Component Material] )
= FALSE ()
),
"BOM Material", [BOM Material],
"Component Material", [Component Material],
"Level", 1
),
ADDCOLUMNS (
SELECTCOLUMNS (
FILTER (
CROSSJOIN (
'OriginalTable',
SELECTCOLUMNS (
'OriginalTable',
"BOM Material2", 'OriginalTable'[BOM Material],
"Component Material2", 'OriginalTable'[Component Material]
)
),
[BOM Material2] = [Component Material]
),
[BOM Material],
"Component Material", [Component Material2]
),
"Level", 2
)
)
Result:
I have attached the pbix for this example below, I hope it helps!
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.