<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Counting parts in multilevel BOM in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-parts-in-multilevel-BOM/m-p/3233983#M118766</link>
    <description>&lt;P&gt;Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot). &lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 14 May 2023 00:11:46 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2023-05-14T00:11:46Z</dc:date>
    <item>
      <title>Counting parts in multilevel BOM</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-parts-in-multilevel-BOM/m-p/3230963#M118552</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;after many months of reading in this forum, this is my first post.&lt;/P&gt;&lt;P&gt;I hope I learned much and am able to write it clearly enough to find a good solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two lists. One bill of material which contains parent-child relations. And one list which marks the product I want to see.&lt;/P&gt;&lt;P&gt;For every product in the second list, I want to know how many parts X it contains. The problem is that Product 'A' can, for example, contain 2 items 'B'. And one item 'B' contains 3 items 'X'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to summarize it with PRODUCTX() but it seems I messed something up with the filter contexts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a minimal example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expected this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But get this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my DAX-Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;DEFINE
    VAR billOffMaterials =
        SELECTCOLUMNS (
            { ( "A", 2, "B" ), ( "B", 3, "X" ), ( "C", 4, "X" ) },
            "Parent", [Value1],
            "Quantity", [Value2],
            "Child", [Value3]
        )
    VAR markedProducts = { ( "A" ), ( "C" ) }
    VAR joinedTable =
        GENERATE (
            markedProducts,
            FILTER (
                billOffMaterials,
                FALSE ()
                    || [Parent] = [Value]
                    || [Parent]
                        IN SELECTCOLUMNS (
                            FILTER ( billOffMaterials, [Value] = [Parent] ),
                            "Child", [Child]
                        )
            )
        )

EVALUATE
joinedTable
ORDER BY [Value]

EVALUATE
SUMMARIZE ( joinedTable, [Value], "Quatity", PRODUCTX ( joinedTable, [Quantity] ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 15:48:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-parts-in-multilevel-BOM/m-p/3230963#M118552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-05-11T15:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Counting parts in multilevel BOM</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-parts-in-multilevel-BOM/m-p/3233983#M118766</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot). &lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2023 00:11:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-parts-in-multilevel-BOM/m-p/3233983#M118766</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2023-05-14T00:11:46Z</dc:date>
    </item>
  </channel>
</rss>

