<?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: DAX calculations totals by group by -multiple columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4150815#M164923</link>
    <description>&lt;P&gt;Yes, the data model could be better but some of those tables are carry overs from previous attempts at getting this right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main tables I use in my current version are:&lt;/P&gt;&lt;P&gt;tbl_InventoryResourcePlanning&lt;/P&gt;&lt;P&gt;tbl_CI_Items&lt;/P&gt;&lt;P&gt;MeasuresTable (just a holding table for the measures)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model could be better but the challenge is that the requirement calls for aggregating quantities at the component level while the only way to determine date ranges is at the sales order level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales Order has many lines (and also contains date and if forecast or actual order, which are both slicers/filters)&lt;/P&gt;&lt;P&gt;Each line has an Item with N quantities&lt;/P&gt;&lt;P&gt;Each Item is made up of a Bill of materials&amp;nbsp;&lt;/P&gt;&lt;P&gt;A Bill of materials contains N components each with a certain amount of each required to produce the item&lt;/P&gt;&lt;P&gt;A component on the bill of materials is itself an Item&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Items Table CI Items contains the Product Line (another filter / slicer) and current inventory on hand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Sep 2024 14:51:44 GMT</pubDate>
    <dc:creator>EricPad</dc:creator>
    <dc:date>2024-09-14T14:51:44Z</dc:date>
    <item>
      <title>DAX calculations totals by group by -multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4148331#M164844</link>
      <description>&lt;P&gt;Hello Community -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on an Inventory Resource / Materials Resource Planning report and I am struggling to get some of my calculations working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data is coming from an ERP system (Sage) and is using Sales order header and detail tables and Bill of material tables.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sales orders contain Items on order. The Bill of materials tables contains hierarchical data of Item and then N levels of components.&amp;nbsp;I needed to include the sales order data to come up with the Date ranges of orders and quantities of orders. I did a ton of data preparation in the SQL Server tables and with stored procedures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially I have to come up with materials required from a set of sales orders and bills of materials. I need to subtract current item quantity on hand values from the item level and then each sub item (component). I have the current on hand values in a related table in my power bi model.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to come up with Quantity ordered by Item Code / Component Item Code Groups. I will then use that value to compare against on hand values to determine if I need to go down to the next component item level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I come up with either a calculated column or measure to get a quantity ordered by Item Code &amp;amp; Component Item Code groupings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of this is here:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example , it should be a quantity ordered of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My visual looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ultimately the challenge is that the quantities ordered are at the Item level but I need to display inventory and materials required at the Component Item level and filtered by date, product line, and Is Forecast or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A copy of my PBIX can be found here:&amp;nbsp;&lt;A href="https://drive.google.com/drive/folders/1zyXpvaBYeZQvekOUYcF2EhaSOamkf0Da?usp=sharing" target="_blank"&gt;https://drive.google.com/drive/folders/1zyXpvaBYeZQvekOUYcF2EhaSOamkf0Da?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eric&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 01:51:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4148331#M164844</guid>
      <dc:creator>EricPad</dc:creator>
      <dc:date>2024-09-13T01:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculations totals by group by -multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4150325#M164903</link>
      <description>&lt;P&gt;Challenge yourself on the data model&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this truly reflecting your business scenario?&amp;nbsp; Can you eliminate the bidirectional link? Should some tables be disconnected?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 23:26:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4150325#M164903</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-09-13T23:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculations totals by group by -multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4150815#M164923</link>
      <description>&lt;P&gt;Yes, the data model could be better but some of those tables are carry overs from previous attempts at getting this right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main tables I use in my current version are:&lt;/P&gt;&lt;P&gt;tbl_InventoryResourcePlanning&lt;/P&gt;&lt;P&gt;tbl_CI_Items&lt;/P&gt;&lt;P&gt;MeasuresTable (just a holding table for the measures)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model could be better but the challenge is that the requirement calls for aggregating quantities at the component level while the only way to determine date ranges is at the sales order level.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales Order has many lines (and also contains date and if forecast or actual order, which are both slicers/filters)&lt;/P&gt;&lt;P&gt;Each line has an Item with N quantities&lt;/P&gt;&lt;P&gt;Each Item is made up of a Bill of materials&amp;nbsp;&lt;/P&gt;&lt;P&gt;A Bill of materials contains N components each with a certain amount of each required to produce the item&lt;/P&gt;&lt;P&gt;A component on the bill of materials is itself an Item&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Items Table CI Items contains the Product Line (another filter / slicer) and current inventory on hand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2024 14:51:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4150815#M164923</guid>
      <dc:creator>EricPad</dc:creator>
      <dc:date>2024-09-14T14:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculations totals by group by -multiple columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4151948#M164996</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="791170" data-lia-user-login="EricPad" class="lia-mention lia-mention-user"&gt;EricPad&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;lbendlin&amp;nbsp; for the quick reply. I have some other thoughts to add:&lt;/P&gt;
&lt;P&gt;We can create a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
CALCULATE (
    SUM ( tbl_InvetoryResourcePlanning[QuantityOrdered] ),
    FILTER (
        ALL ( 'tbl_InvetoryResourcePlanning' ),
        [ComponentItemCode] = MAX ( 'tbl_InvetoryResourcePlanning'[ComponentItemCode] )
            &amp;amp;&amp;amp; [ShipExpireDate]
                IN VALUES ( 'tbl_InvetoryResourcePlanning'[ShipExpireDate] )
                    &amp;amp;&amp;amp; [IsForecastAcct]
                        IN VALUES ( 'tbl_InvetoryResourcePlanning'[IsForecastAcct] )
                            &amp;amp;&amp;amp; [ComponentProductLine]
                                IN VALUES ( 'tbl_InvetoryResourcePlanning'[ComponentProductLine] )
    )
)
&lt;/LI-CODE&gt;
&lt;P&gt;Then the result is as follows.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 07:24:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculations-totals-by-group-by-multiple-columns/m-p/4151948#M164996</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-16T07:24:42Z</dc:date>
    </item>
  </channel>
</rss>

