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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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