<?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: Dynamic Unit Price Lookup DAX Measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763836#M146880</link>
    <description>&lt;P&gt;Absolutely right&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2024 13:55:08 GMT</pubDate>
    <dc:creator>asif999</dc:creator>
    <dc:date>2024-03-14T13:55:08Z</dc:date>
    <item>
      <title>Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761312#M146746</link>
      <description>&lt;P&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1LnutkGNIwTWLGyiGthCo6u0ZOcSQ-jOHOYYwYtoU2m0/edit?usp=sharing" target="_self"&gt;&lt;STRONG&gt;Google Sheet Link&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;1. I want to calculate the Amount dax measure as shown in Sales[Amount] col.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. For the earliest transaction in the Sales Table, I want to look for the earliest SKU rate from the Purchase Table to calculate the amount.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. There could be a situation where a multi-qty transaction of the same SKU would have different rates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for example → Have a look at 2nd transaction. This transaction has 3 units and the amount is calculated as, for the first 2 units the rate is 100 and for the 3rd unit the rate is 120.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So the amount would be 2 X 100 + 1 X 120 = 320&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 17:02:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761312#M146746</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-13T17:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761326#M146747</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;&amp;nbsp;I'm not quite able to unwind your logic here but seems like some form of application of this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434" target="_blank"&gt;Lookup Min/Max - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 17:07:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761326#M146747</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2024-03-13T17:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761500#M146760</link>
      <description>&lt;P&gt;So I have a Sales Table(Fact Table), Purchase Table(Fact Table) and SKU(Dim Table).&lt;BR /&gt;Relationships are as→&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I want to calculate the &lt;STRONG&gt;Amount Column&lt;/STRONG&gt; in the &lt;STRONG&gt;Sales table&lt;/STRONG&gt; which is &lt;STRONG&gt;Sales[Qty]*Purchase[Rate].&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But the catch is that &lt;STRONG&gt;Purchase Table&lt;/STRONG&gt; have different rates for an SKU.&lt;/P&gt;&lt;P&gt;So based on the chronological order to calculate the &lt;STRONG&gt;Amount Col&lt;/STRONG&gt; in the Sales table, I want to first look at the early transaction of an SKU in the&amp;nbsp;&lt;STRONG&gt;Sales Table&lt;/STRONG&gt; and then extract the early &lt;STRONG&gt;Purchase rate&lt;/STRONG&gt; of that SKU from the &lt;STRONG&gt;Purchase Table&amp;nbsp;&lt;/STRONG&gt;and multiply it with &lt;STRONG&gt;Sales[Qty].&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;For earlier SKU transactions in the Sales table, I want to get the earlier&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;Rates From Purchase Table.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;For Ex&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Refer to SKU BT-01&lt;/FONT&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;All rates for BT-01 are arranged from the purchase table from oldest to newest date Purchase[Qty]*Purchase[Rate], let say BT-01_AllRates = (4 X &lt;FONT color="#FF0000"&gt;100&lt;FONT color="#000000"&gt;,&lt;/FONT&gt;&amp;nbsp;&lt;/FONT&gt;6 X &lt;FONT color="#FF0000"&gt;120&lt;FONT color="#000000"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;10 X &lt;FONT color="#FF0000"&gt;90&lt;/FONT&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;For 1st BT-01 Transaction in Sales Table, Amount = Sales[Qty] * EarlyRate(BT-01_AllRates) =&amp;gt;2 X 100 = 200 and BT-01_AllRates updates to (2 X &lt;FONT color="#FF0000"&gt;100,&lt;FONT color="#000000"&gt; 6 X&lt;/FONT&gt; 120, &lt;FONT color="#000000"&gt;10 X&lt;/FONT&gt; 90&lt;/FONT&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For 2nd BT-01 Transaction in Sales Table, Amount = Sales[Qty] * EarlyRate(BT-01_AllRates) =&amp;gt;2 X 100 + 1 X 120= 320 and BT-01_AllRates updates to (0 X &lt;FONT color="#FF0000"&gt;100,&lt;FONT color="#000000"&gt;&amp;nbsp;5 X&lt;/FONT&gt; 120, &lt;FONT color="#000000"&gt;10 X&lt;/FONT&gt; 90&lt;/FONT&gt;)&lt;BR /&gt;&lt;BR /&gt;I hope you get it now.&amp;nbsp;&lt;/STRONG&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;&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;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 18:44:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3761500#M146760</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-13T18:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763821#M146878</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me try to rephrase what you said from what I understood:&lt;/P&gt;&lt;P&gt;1. BT-01 1st transaction - There is 2 quantity in the sales table and 4 quantity in the Purchase table. So 2 * 100 = 200&lt;/P&gt;&lt;P&gt;2. BT-01 2nd transaction - There is 3 quantity in the sale stable and 2 quantity in the Purchase table (after reducing 2 because of 1st transaction). So, 2 * 100 + 1 * 120&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is my understanding right?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 13:47:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763821#M146878</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2024-03-14T13:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763836#M146880</link>
      <description>&lt;P&gt;Absolutely right&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 13:55:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763836#M146880</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-14T13:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763973#M146883</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the date play a role in getting the price of SKUs? Like the sales transaction date should fall between the purchase dates from which we are using?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think we can express this in DAX but it would be way too complex. Why not do it in Data engineering?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 15:23:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3763973#M146883</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2024-03-14T15:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3764659#M146912</link>
      <description>&lt;P&gt;Yes, the date plays a role in getting the price for the SKUs.&lt;BR /&gt;&lt;BR /&gt;In the sales table, it should pick up the SKU transaction in oldest to newest fashion and feed the rate from purchase table in the same fashion.&lt;BR /&gt;&lt;BR /&gt;Yes, we can do it in data engineering but how?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 23:37:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3764659#M146912</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-14T23:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3765037#M146927</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Data engineering, we normally calculate the difference in SKUs and store it in separate table as part of processing. And then we use that table for calculating the current transaction.&amp;nbsp;Usually we use the LAG, LEAD function in SQL.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In terms of DAX, I believe we have a way to do this by using the order date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Give me some time, I will try to work out a DAX formula.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 03:32:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3765037#M146927</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2024-03-15T03:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3765093#M146930</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="644992" data-lia-user-login="govindarajan_d" class="lia-mention lia-mention-user"&gt;govindarajan_d&lt;/a&gt;, just wanted to drop a quick thank you for your assistance. Looking forward to your response – much appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 04:42:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3765093#M146930</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-15T04:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3770310#M147255</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to work on it over the weekend. One of the major problems that I couldn't overcome was the stock distribution across different rows. Usually we can aggregate the rows and use it for calculation, but in this case it is a calculation that is split across different rows.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying different formulas, but I just have an intermediate experience working with DAX. You can try tagging some of the experts to see if they can solve this!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 07:02:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3770310#M147255</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2024-03-18T07:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3787343#M147938</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="644992" data-lia-user-login="govindarajan_d" class="lia-mention lia-mention-user"&gt;govindarajan_d&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thanks for trying.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Mar 2024 08:06:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3787343#M147938</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-23T08:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3787878#M147989</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see if this work for you. It involves joins so will be slow if there are too many average# of records for each SKU.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note : My advise is to do it in Power Query, it is very easy to implement in Power Query.&lt;/P&gt;&lt;P&gt;Assumption : SKU and OrderID combination is unique&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Created Sales and Purchase table(Only two tables without any relationship between them)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please create this measure, it is for Sales Amount only.&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SalesAmount = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _SKU = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/S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&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(_SummTbl, &lt;/SPAN&gt;&lt;SPAN&gt;"@JoinColumn"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;(_SummTbl, (([OrderID]*&lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;SPAN&gt;)+[Value]),,&lt;/SPAN&gt;&lt;SPAN&gt;ASC&lt;/SPAN&gt;&lt;SPAN&gt;, Dense ) ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"@SKUSales"&lt;/SPAN&gt;&lt;SPAN&gt;, [SKU],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"@OrderIDSales"&lt;/SPAN&gt;&lt;SPAN&gt;, [OrderID],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"@JoinColumn"&lt;/SPAN&gt;&lt;SPAN&gt;, [@JoinColumn]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&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&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _JoinSalesPurchase = &lt;/SPAN&gt;&lt;SPAN&gt;NATURALINNERJOIN&lt;/SPAN&gt;&lt;SPAN&gt;(_AddRankSales, _AddRankPurchase)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _SummResult = &lt;/SPAN&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;(_JoinSalesPurchase, [@SKUSales], [@OrderIDSales]), &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"@SalesAmount"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt;&lt;SPAN&gt; _OrderID = [@OrderIDSales]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;SUMX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(_JoinSalesPurchase, [@OrderIDSales] = _OrderID),[Rate])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;SELECTCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(_SummResult, [@SKUSales] = _SKU &amp;amp;&amp;amp; [@OrderIDSales] = _SalesOrderID), &lt;/SPAN&gt;&lt;SPAN&gt;"@SalesAmount"&lt;/SPAN&gt;&lt;SPAN&gt;, [@SalesAmount])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;--------------------------------------------------------------------------------------------------&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 05:16:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3787878#M147989</guid>
      <dc:creator>talespin</dc:creator>
      <dc:date>2024-03-24T05:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3797343#M148409</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="678168" data-lia-user-login="talespin" class="lia-mention lia-mention-user"&gt;talespin&lt;/a&gt;&amp;nbsp;thank you for posting the solution.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;Awesome this is working great&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have thousands of these records in my database and I am wondering if this solution is ideal for faster calculations as the filter function is being used up on multiple instances that can slow down the performance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.1 - Could you please briefly explain the logic behind your solution?&lt;/STRONG&gt; &lt;/FONT&gt;(I am new to DAX)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.2 - How to do this in Power Query? SKU and Order combinations are unique.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.3 - There are instances where a specific problem can be solved with both the power query and DAX. What to choose between these two with regard to performance/faster calculation?&lt;/STRONG&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 16:40:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3797343#M148409</guid>
      <dc:creator>asif999</dc:creator>
      <dc:date>2024-03-28T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Unit Price Lookup DAX Measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3798066#M148450</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="535619" data-lia-user-login="asif999" class="lia-mention lia-mention-user"&gt;asif999&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"I have thousands of these records in my database and I am wondering if this solution is ideal for faster calculations as the filter function is being used up on multiple instances that can slow down the performance." -&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can be achieved both with Power Query and DAX.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You need to see, do you have any slicers that may impact your calculation?&lt;/P&gt;&lt;P&gt;For Example If you have a slicer on Purchase table and Amount Calculation should take into account this slicer, in that case you definately need DAX but otherwise use Power Query in this case.&lt;/P&gt;&lt;P&gt;As for performance, if number of records per SKU is small, then DAX should work fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.1 - Could you please briefly explain the logic behind your solution?&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;(I am new to DAX)&lt;/P&gt;&lt;P&gt;I am expanding both tables based on Quantity column, if SKU-Order ID has quantity of 3, I am expanding single row into three rows, similarly for all rows and both tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I rank them for each SKU based on date, also making sure each row has a unique sequence number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I join(inner join) the two tables on this unique number and sum the rate from Purchase table to get Amount value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.2 - How to do this in Power Query? SKU and Order combinations are unique.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Use same logic as above, expand both tables into as many rows as value in Quantity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this. For each SKU you should have a unique sequence number and then Join the two tables on this number.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=qWJEjXiNFyI" target="_blank"&gt;[Power Query] Repeat Row N Times (youtube.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Q.3 - There are instances where a specific problem can be solved with both the power query and DAX. What to choose between these two with regard to performance/faster calculation?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;That depends on lot of factors. Its not like one solution works for all.&lt;/P&gt;&lt;P&gt;Do you have a slicer that may require calculation using DAX?&lt;/P&gt;&lt;P&gt;If you create a column in Power Query you get better compression but Power BI file will still consume space for every column added.&lt;/P&gt;&lt;P&gt;DAX may perform slower in certain scenarios.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2024 05:33:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Dynamic-Unit-Price-Lookup-DAX-Measure/m-p/3798066#M148450</guid>
      <dc:creator>talespin</dc:creator>
      <dc:date>2024-03-29T05:33:26Z</dc:date>
    </item>
  </channel>
</rss>

