<?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 Use freshest cost to date available for margin calculation, per day per site per product in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-freshest-cost-to-date-available-for-margin-calculation-per/m-p/1808930#M38197</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to estimate margin (using Current Cost of Sales accounting logic) based on my proceeds and cost tables,&lt;STRONG&gt;&amp;nbsp;using always the latest best cost info available at the given point in time.&lt;/STRONG&gt; I was looking for solutions, but they either give me always the latest cost available (no ok for historical calc.), or I am warned against (EARLIER: lots of computing power if used on big tables; FILTER: used on Data tables instead of reference tables). I operate this currently in Excel (per month, maxifs), and it is very slow, so I am looking for optimum performance, grateful for advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Deliveries table. Costs, per day, per site, per product, per depot&lt;/STRONG&gt;. Obviously lots of deliveries, so usually I would have a delivery per day per depot. (Meaning: if I know the depot that was used last to supply my site, I can pick up the freshest cost info for that depot.)&lt;/P&gt;&lt;P&gt;- I have day/site/product combinations when there is no delivery (&lt;FONT color="#FF00FF"&gt;magenta&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- I have combinations when there are multiple deliveries – two depots (&lt;FONT color="#339966"&gt;green&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- I have combinations where a site is changing over time from Depot1 to Depot2 (&lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- cca ~30.000 delivery combinations/month (this includes depot layer as well)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sales table. Proceeds and quantities sold, per day, per site, per product.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For each combination (~30-40k rows per month), need to know freshest cost info until any given day to enable margin calculation.&lt;/P&gt;&lt;P&gt;1. last delivery to the site, for the given product, until the given day&lt;/P&gt;&lt;P&gt;2. the depot used for this delivery (largest delivery in case more deliveries per day) - "which depot supplied the site last?"&lt;/P&gt;&lt;P&gt;3. the freshest cost information available for the given depot, for (or closest up to) the given day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have reference tables for site, day, products, depots. The two data tables (sales and deliveries) are both linked to my reference tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table examples below, with results expected.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;Delivery table example: (also used to calculate unit cost)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Posting date;SiteCode;Depot;Product code;Quantity;Total Cost&lt;/P&gt;&lt;P&gt;2021.03.01;11111111;BR1008;123456789;1 040;-31 006&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;2021.03.05;11111111;BR1007;123456789;5 870;-175 797&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;2021.03.05;11111111;BR1008;123456789;10 690;-320 149; two deliveries on the same day/site/product&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;2021.03.03;11111111;BR1008;345678901;5 920;-177 265&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;2021.03.06;11111111;BR1008;345678901;11 050;-330 875; no deliveries (but sales yes!) for the 4th&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;2021.03.08;11111111;BR1008;345678901;4 810;-131 711&lt;/P&gt;&lt;P&gt;2021.03.02;22222222;BR1000;123456789;3 590;-100 985&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.01;22222222;BR1000;345678901;6 790;-174 270&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.03;22222222;BR3098;345678901;2 300;-60 648&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.05;22222222;BR3220;345678901;4 710;-125 591; depots changing over time&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales table example,&lt;STRONG&gt; including results expected&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;Green&lt;/FONT&gt;: pick depot with the biggest quantity&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;Magenta&lt;/FONT&gt;: use depot that last sent this product here&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Red&lt;/FONT&gt;: depot changes over time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product code;Selling date;Site;Proceeds;Quantity;RESULT: last biggest delivery to site;RESULT: Depot used for last deliv.;RESULT: freshest cost info to date&lt;/P&gt;&lt;P&gt;123456789;01.03.2021;11111111;21 556;440;1040;BR1008;-29,81&lt;/P&gt;&lt;P&gt;123456789;04.03.2021;11111111;116 596;2380;1040;BR1008;-29,81&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;123456789;05.03.2021;11111111;78 874;1610;10690;BR1008;-29,94&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;345678901;04.03.2021;11111111;14 697;300;5920;BR1008;-29,94&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;123456789;02.03.2021;22222222;263 724;5530;3590;BR1000;-28,1&lt;/P&gt;&lt;P&gt;123456789;07.03.2021;22222222;96 821;2030;3590;BR1000;-28,1&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;01.03.2021;22222222;344 551;7150;6790;BR1000;-25,6&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;04.03.2021;22222222;216 339;4480;2300;BR3098;-26,3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;05.03.2021;22222222;201 852;4180;4710;BR3220;-26,6&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Apr 2021 12:41:38 GMT</pubDate>
    <dc:creator>iyqp93</dc:creator>
    <dc:date>2021-04-27T12:41:38Z</dc:date>
    <item>
      <title>Use freshest cost to date available for margin calculation, per day per site per product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-freshest-cost-to-date-available-for-margin-calculation-per/m-p/1808930#M38197</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to estimate margin (using Current Cost of Sales accounting logic) based on my proceeds and cost tables,&lt;STRONG&gt;&amp;nbsp;using always the latest best cost info available at the given point in time.&lt;/STRONG&gt; I was looking for solutions, but they either give me always the latest cost available (no ok for historical calc.), or I am warned against (EARLIER: lots of computing power if used on big tables; FILTER: used on Data tables instead of reference tables). I operate this currently in Excel (per month, maxifs), and it is very slow, so I am looking for optimum performance, grateful for advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Deliveries table. Costs, per day, per site, per product, per depot&lt;/STRONG&gt;. Obviously lots of deliveries, so usually I would have a delivery per day per depot. (Meaning: if I know the depot that was used last to supply my site, I can pick up the freshest cost info for that depot.)&lt;/P&gt;&lt;P&gt;- I have day/site/product combinations when there is no delivery (&lt;FONT color="#FF00FF"&gt;magenta&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- I have combinations when there are multiple deliveries – two depots (&lt;FONT color="#339966"&gt;green&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- I have combinations where a site is changing over time from Depot1 to Depot2 (&lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt; in example)&lt;/P&gt;&lt;P&gt;- cca ~30.000 delivery combinations/month (this includes depot layer as well)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sales table. Proceeds and quantities sold, per day, per site, per product.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For each combination (~30-40k rows per month), need to know freshest cost info until any given day to enable margin calculation.&lt;/P&gt;&lt;P&gt;1. last delivery to the site, for the given product, until the given day&lt;/P&gt;&lt;P&gt;2. the depot used for this delivery (largest delivery in case more deliveries per day) - "which depot supplied the site last?"&lt;/P&gt;&lt;P&gt;3. the freshest cost information available for the given depot, for (or closest up to) the given day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have reference tables for site, day, products, depots. The two data tables (sales and deliveries) are both linked to my reference tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table examples below, with results expected.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;Delivery table example: (also used to calculate unit cost)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Posting date;SiteCode;Depot;Product code;Quantity;Total Cost&lt;/P&gt;&lt;P&gt;2021.03.01;11111111;BR1008;123456789;1 040;-31 006&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;2021.03.05;11111111;BR1007;123456789;5 870;-175 797&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;2021.03.05;11111111;BR1008;123456789;10 690;-320 149; two deliveries on the same day/site/product&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;2021.03.03;11111111;BR1008;345678901;5 920;-177 265&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;2021.03.06;11111111;BR1008;345678901;11 050;-330 875; no deliveries (but sales yes!) for the 4th&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;2021.03.08;11111111;BR1008;345678901;4 810;-131 711&lt;/P&gt;&lt;P&gt;2021.03.02;22222222;BR1000;123456789;3 590;-100 985&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.01;22222222;BR1000;345678901;6 790;-174 270&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.03;22222222;BR3098;345678901;2 300;-60 648&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;2021.03.05;22222222;BR3220;345678901;4 710;-125 591; depots changing over time&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sales table example,&lt;STRONG&gt; including results expected&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;Green&lt;/FONT&gt;: pick depot with the biggest quantity&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;Magenta&lt;/FONT&gt;: use depot that last sent this product here&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Red&lt;/FONT&gt;: depot changes over time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product code;Selling date;Site;Proceeds;Quantity;RESULT: last biggest delivery to site;RESULT: Depot used for last deliv.;RESULT: freshest cost info to date&lt;/P&gt;&lt;P&gt;123456789;01.03.2021;11111111;21 556;440;1040;BR1008;-29,81&lt;/P&gt;&lt;P&gt;123456789;04.03.2021;11111111;116 596;2380;1040;BR1008;-29,81&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00FF00"&gt;123456789;05.03.2021;11111111;78 874;1610;10690;BR1008;-29,94&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF00FF"&gt;345678901;04.03.2021;11111111;14 697;300;5920;BR1008;-29,94&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;123456789;02.03.2021;22222222;263 724;5530;3590;BR1000;-28,1&lt;/P&gt;&lt;P&gt;123456789;07.03.2021;22222222;96 821;2030;3590;BR1000;-28,1&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;01.03.2021;22222222;344 551;7150;6790;BR1000;-25,6&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;04.03.2021;22222222;216 339;4480;2300;BR3098;-26,3&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;345678901;05.03.2021;22222222;201 852;4180;4710;BR3220;-26,6&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 12:41:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-freshest-cost-to-date-available-for-margin-calculation-per/m-p/1808930#M38197</guid>
      <dc:creator>iyqp93</dc:creator>
      <dc:date>2021-04-27T12:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Use freshest cost to date available for margin calculation, per day per site per product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-freshest-cost-to-date-available-for-margin-calculation-per/m-p/1810845#M38242</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="298313" data-lia-user-login="iyqp93" class="lia-mention lia-mention-user"&gt;iyqp93&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at this... I don't think it's workable here on the forum. At least not with the current description. Since one can't see the live data and have a clear understanding of the model and relationships, I think it will be very difficult to give you any type of advice. But might be wrong. Maybe it's just me no being able to fully grasp your problem. Sorry.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 08:20:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Use-freshest-cost-to-date-available-for-margin-calculation-per/m-p/1810845#M38242</guid>
      <dc:creator>daxer-almighty</dc:creator>
      <dc:date>2021-04-28T08:20:17Z</dc:date>
    </item>
  </channel>
</rss>

