<?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 Calculations with multiple constraints in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/885838#M7679</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm a uni student doing a final project for my IS degree and have only been using PowerBI for a couple of months.&lt;BR /&gt;&lt;BR /&gt;I'd really appreciate some help to solve the following (Model attached).&lt;BR /&gt;&lt;BR /&gt;I need to be able to calculate product weighted average cost, where most of the tables in the model are separated.&lt;BR /&gt;&lt;BR /&gt;Some items in Product[STOCKCODE] have a list of ingridients they consist of.&lt;BR /&gt;Those ingridients are all grouped under the same HDR[BILLCODE],&amp;nbsp; but different indiividual LINES[STOCKCODE].&lt;BR /&gt;Most of the Ingridients in LINES[STOCKCODE] use Standard costs, but some costs change based on month and year.&lt;BR /&gt;The items with dynamic price are in WAC Cost Table.&lt;BR /&gt;&lt;BR /&gt;Because there are so many conditions I'm getting lost whether tu use calculated&amp;nbsp; column or measures, as both have their own limitations. Or maybe i'm too greedy trying to solve all at once and i need to take smaller steps.&lt;BR /&gt;Hope that's not too complicated.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Tables connections:&lt;/STRONG&gt;&lt;BR /&gt;Product[STOCKCODE]=HDR[OUTPUTCODE],&lt;BR /&gt;HDR[BILLCODE] = LINES[BILLCODE],&lt;BR /&gt;LINES[STOCKCODE] = WAC SUPP[BOM Stock Code],&lt;BR /&gt;WAC SUPP[BOM Stock Code]=WAC Cost Table [BOM Stock Code]&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidelines are higly appreciated.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Dec 2019 02:18:46 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-12-30T02:18:46Z</dc:date>
    <item>
      <title>Calculations with multiple constraints</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/885838#M7679</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm a uni student doing a final project for my IS degree and have only been using PowerBI for a couple of months.&lt;BR /&gt;&lt;BR /&gt;I'd really appreciate some help to solve the following (Model attached).&lt;BR /&gt;&lt;BR /&gt;I need to be able to calculate product weighted average cost, where most of the tables in the model are separated.&lt;BR /&gt;&lt;BR /&gt;Some items in Product[STOCKCODE] have a list of ingridients they consist of.&lt;BR /&gt;Those ingridients are all grouped under the same HDR[BILLCODE],&amp;nbsp; but different indiividual LINES[STOCKCODE].&lt;BR /&gt;Most of the Ingridients in LINES[STOCKCODE] use Standard costs, but some costs change based on month and year.&lt;BR /&gt;The items with dynamic price are in WAC Cost Table.&lt;BR /&gt;&lt;BR /&gt;Because there are so many conditions I'm getting lost whether tu use calculated&amp;nbsp; column or measures, as both have their own limitations. Or maybe i'm too greedy trying to solve all at once and i need to take smaller steps.&lt;BR /&gt;Hope that's not too complicated.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Tables connections:&lt;/STRONG&gt;&lt;BR /&gt;Product[STOCKCODE]=HDR[OUTPUTCODE],&lt;BR /&gt;HDR[BILLCODE] = LINES[BILLCODE],&lt;BR /&gt;LINES[STOCKCODE] = WAC SUPP[BOM Stock Code],&lt;BR /&gt;WAC SUPP[BOM Stock Code]=WAC Cost Table [BOM Stock Code]&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidelines are higly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 02:18:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/885838#M7679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-30T02:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations with multiple constraints</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/885959#M7682</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;let's make a first small step.&lt;/P&gt;&lt;P&gt;could you share an example of your dataset (for example for one product)?&lt;/P&gt;&lt;P&gt;then based on this example try to describe what do you want to get as output and how exactly it should be calculated&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 06:30:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/885959#M7682</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2019-12-30T06:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations with multiple constraints</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/886476#M7711</link>
      <description>&lt;P&gt;Thanks for getting back to me! Here is the sample data.&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;NOTE: &lt;/STRONG&gt;&lt;/U&gt;&lt;STRONG&gt;Output_code=Stockcode &lt;/STRONG&gt;and&lt;STRONG&gt; Description=Description_2 &lt;/STRONG&gt;are same columnsfrom &lt;STRONG&gt;Product table.&lt;/STRONG&gt; Names changed as 1 code&amp;amp;Description belongs to the Finished Product (HVT1KG), while the 2nd one belongs to the product components (Labour, Cheese etc&lt;STRONG&gt;)&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;1. &lt;STRONG&gt;HDR&amp;nbsp;&lt;/STRONG&gt;is just a table where &lt;STRONG&gt;Finished Product&lt;/STRONG&gt; is assigned a Billcode, so its easier to define the &lt;STRONG&gt;Finished Product components&lt;/STRONG&gt;, without referenceing the same &lt;STRONG&gt;Product table in the process.&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;2. Finished &lt;/EM&gt;&lt;STRONG&gt;Product.Standardcost&lt;/STRONG&gt;&amp;nbsp;is calculated by multiplying each ingridient's&amp;nbsp; &lt;STRONG&gt;Product.Standardcost&amp;nbsp;&lt;/STRONG&gt;by&lt;STRONG&gt; LINES.Quantity&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;3. The snapshot is basically the &lt;STRONG&gt;LINES&lt;/STRONG&gt; table (Without Stdcost and WAC)&lt;BR /&gt;&lt;BR /&gt;4. WAC is only applicable to a handfull of Products, the rest uses standard. (i.e for&amp;nbsp; &lt;STRONG&gt;HVT1KG&lt;/STRONG&gt; all components cost to be calculated based on standard, &lt;STRONG&gt;EXCEPT&lt;/STRONG&gt; For &lt;STRONG&gt;CHSRR, t&lt;/STRONG&gt;he cost of which will depend n the date pf the transsaction, as WAAC changes monthly.&lt;BR /&gt;&lt;BR /&gt;4. &lt;STRONG&gt;WAC SUPP&lt;/STRONG&gt; is a table to avoide many to many relationship between LINES and WAC, as neither have unique values:(one &lt;STRONG&gt;LINES.Stockcode&lt;/STRONG&gt; can be a component in many finished products and one &lt;STRONG&gt;WACCostTable.BOMStockCode &lt;/STRONG&gt;appears many times in the table as Wac cost changes monthly.&lt;BR /&gt;&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;Requirement.&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;&lt;BR /&gt;We have Sales fact table, which is connected to Product table.&lt;BR /&gt;&lt;BR /&gt;IF Finished Sold Product has a component, which is listed in the WAC table, use the cost from WAC table, instead of Standard cost.&lt;BR /&gt;WAC will depend on the Product Stockcode and the date of the transacation.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope this makes it clearer.&lt;BR /&gt;Thanks for your time.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 21:57:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/886476#M7711</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-30T21:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations with multiple constraints</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/886896#M7727</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's more clear but its still dificcult to make a full solution&lt;/P&gt;&lt;P&gt;maybe you should try to use ISINSCOPE function&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/dax/isinscope-function-dax" target="_blank"&gt;https://docs.microsoft.com/en-us/dax/isinscope-function-dax&lt;/A&gt;&lt;/P&gt;&lt;P&gt;smth like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = SWITCH( TRUE(),
ISINSCOPE('WAC SUPP'[BOM Stock Code]),
SUM('WAC Cost Table'[WAC]),
SUM('Product'[StandartCost])
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT color="#ababab"&gt;do not hesitate to give a kudo to useful posts and mark solutions as solution&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2019 10:05:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/886896#M7727</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2019-12-31T10:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations with multiple constraints</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/897296#M8127</link>
      <description>&lt;P&gt;Thanks for your response.&lt;BR /&gt;&lt;BR /&gt;The solution sums all WAC values for a particular Product, however the fact also depends on the date of the transaction.&lt;BR /&gt;Hence Cost at WAC will depend on&lt;BR /&gt;1. ProductID (if its inscope of the BOM Stockcodes)&lt;BR /&gt;2. Date of transaction (If its within certain Month and Year in WAC Table (Invoice date inscope of WAC Cost table MonthYear)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 00:39:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculations-with-multiple-constraints/m-p/897296#M8127</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-13T00:39:26Z</dc:date>
    </item>
  </channel>
</rss>

