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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
lionx
Helper I
Helper I

Correct measure to count number of components in BOM structure

Could you please help me to correct the measure to show the number of components in each layer of BOM as described in the picture? 

 

lionx_1-1682556697267.png

 

I have created the two measures below but they do not works. I also attached the link to download pbi desktop file for your inspection. 

 

Total items =
VAR Val = DISTINCTCOUNTNOBLANK(flattenHierrachy[no])
VAR EntityShowRow =
    [BrowseDepth] <= [BrowseDepth]
VAR Result =
    IF ( EntityShowRow, Val )
RETURN
    Result
 
 
Count components of earlier level =
IF (
    [BrowseDepth] > [MaxNodeDepth],
    BLANK (),
        IF([BOM] = "L0", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 1] ),
            IF([BOM] = "L1", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 2] ),
                IF([BOM] = "L2", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 3] ),
                    IF([BOM] = "L3", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 4] ),
                        IF([BOM] = "L4", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 5] ),
                            IF([BOM] = "L5", DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Level 6] ),
                                DISTINCTCOUNTNOBLANK( 'flattenHierrachy'[Assembly Item] )
)))))))
 

The link to download the .pbix file  
https://bit.ly/3HhW8WE

1 ACCEPTED SOLUTION

Hi Ibendlin,

 

Thank you very much for your time. I have corrected the issue by myself with the same logic as the code block above. 

 

 

 

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

You have a couple of problems. One of them is that you don't really have a hierarchy.

 

lbendlin_0-1682805506407.png

 

As you can see a substantial number of items have multiple parents.  That's a no-no in a hierarchy.

 

You are better off with a snowflake style data model where you describe for each actual product what their BOM is, and then for these components what their sub-BOM is etc.

Hi Ibendlin,

 

Thank you very much for your time. I have corrected the issue by myself with the same logic as the code block above. 

 

 

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.