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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
EmielvdR
Frequent Visitor

Find all parents in Bom parent child hierarchy based on property

I 'm trying to implement a Bill of materail view in a PowerBI table visual based on a slicer on MaterialDescription.

 

The goal is:

- Select a MaterialDescription in the slicer

- Table shows all materials found in de vFactBOM

- Table also shows all parents in the table visual (PATHCONTAINS) and removes parents which do based on the value of PropertyA of that specific parent

 

The data model look like this:

Facttable vFactBOM (which contains a Bill of Material including calculated column BOMLinePath=PATH(BOMLineID,BOMLineIDParent))

A Dimension table DimMaterial linked with MaterialID to vFactBOM (Dim 1:* Fact) (with MaterialID, MaterialDescription, BOMLinePath, PropertyA)

A unrelated calculated table BOMSlicerNames, which is a calculated table with SELECTCOLUMNS of DimMaterial (with MaterialID, MaterialDescription, BOMLinePath, PropertyA)

(this concept is implemented based on post: https://community.fabric.microsoft.com/t5/Desktop/Filter-Table-by-Column-Values-Associated-with-Sele...)

 

Current measures:

 

 

 

MEASURE vFactBOM[BOMSlicer_Measure] = 
CALCULATE (
    SELECTEDVALUE ( vFactBOM[BOMLinePath] ),
    TREATAS ( VALUES ( BOMSlicerNames[BOMLinePath] ), vFactBOM[BOMLinePath] )
)

MEASURE vFactBOM[QtyCum] =
VAR myp = vFactBOM[BOMSlicer_Measure] // will be empty when multiple or non-selected
VAR myval =
    IF (
        NOT (
            ISBLANK ( vFactBOM[BOMSlicer_Measure] )
        ),
        // Don't execute when not needed
        CALCULATE (
            PRODUCTX (
                vFactBOM,
                vFactBOM[Quantity]
            ),
            FILTER (
                ALL ( vFactBOM ),
                PATHCONTAINS (
                    myp // the path to search in
                    ,
                    vFactBOM[BOMLineID] // the item to search for
                ) = TRUE
            )
        )
    )
RETURN
    myval

 

 

 

The current measures help me to select the correct materials from the vFactBOM, since QtyCum will only show a value for the selected materials.

Now I need a additional measure to do the same but also showing the parents (based on PropertyA).

 

How can I make a measure which results in showing the correct lines?

 

I hope this explaintion is clear enough to give me some suggestions.

Setup:
Direct query mode with Tabular Azure Analysis services

1 ACCEPTED SOLUTION
EmielvdR
Frequent Visitor

Thank you I found a solution which works in dax (in direct query mode) myself.

 

ShowParents:=
var myp = 
  COUNTROWS(
  FILTER(
    CROSSJOIN(
      // Selected value in slicer
      VALUES(BOMSlicerNames[BOMLinePath]),
       // FACT value
      VALUES(vFactBOM[BOMLinePath])
    ),
    LEFT(BOMSlicerNames[BOMLinePath], LEN(vFactBOM[BOMLinePath])) = vFactBOM[BOMLinePath] 
    &&
    SELECTEDVALUE(PLM_vDimMaterial[PropertyA])="002"
    )
  )
        
RETURN myp

 

Addin this metric to the table show the number of parents and is blank if the item doesn't match the criteria (in this case match on Path and PropertyA = 002.

View solution in original post

4 REPLIES 4
EmielvdR
Frequent Visitor

Thank you I found a solution which works in dax (in direct query mode) myself.

 

ShowParents:=
var myp = 
  COUNTROWS(
  FILTER(
    CROSSJOIN(
      // Selected value in slicer
      VALUES(BOMSlicerNames[BOMLinePath]),
       // FACT value
      VALUES(vFactBOM[BOMLinePath])
    ),
    LEFT(BOMSlicerNames[BOMLinePath], LEN(vFactBOM[BOMLinePath])) = vFactBOM[BOMLinePath] 
    &&
    SELECTEDVALUE(PLM_vDimMaterial[PropertyA])="002"
    )
  )
        
RETURN myp

 

Addin this metric to the table show the number of parents and is blank if the item doesn't match the criteria (in this case match on Path and PropertyA = 002.

lbendlin
Super User
Super User

Bill of Materials (BOM) solution in Excel and PowerBI – (thebiccountant.com)

 

Keep in mind that Power BI is a reporting tool, not a material planning tool.

Thank you for the reply. I also found this solution, but m-query is not possible in direct query mode.

Instead of Direct Query you can access your SSAS Tabular source tables in import mode. That butchers the entire concept of SSAS but will allow you to run the M code.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.