<?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: Looking up the correct value from a table with values per periods, based on a unique date in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707561#M35239</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="216811" data-lia-user-login="Brandaris" class="lia-mention lia-mention-user"&gt;Brandaris&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a calculated column in the Orders table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Price =
CALCULATE (
    DISTINCT ( CostPrices[Cost price] ),
    FILTER (
        ALL ( CostPrices[product ID], CostPrices[start date], CostPrices[end date] ),
        CostPrices[product ID] = Orders[product ID]
            &amp;amp;&amp;amp; CostPrices[start date] &amp;lt;= Orders[date]
            &amp;amp;&amp;amp; CostPrices[end date] &amp;gt; Orders[date]
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 100px; width: 100%; border-collapse: collapse; border-style: groove; border-color: #0c1c49; background-color: #00675f;" border="0" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15px;"&gt;
&lt;TD width="15.961305925030231%" style="width: 92px; height: 15px;"&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.03869407496977%" style="width: 485px; height: 15px; text-align: left;"&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Please accept the solution when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4.5" color="#FF99CC"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Mar 2021 22:27:26 GMT</pubDate>
    <dc:creator>AlB</dc:creator>
    <dc:date>2021-03-07T22:27:26Z</dc:date>
    <item>
      <title>Looking up the correct value from a table with values per periods, based on a unique date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707457#M35234</link>
      <description>&lt;P&gt;Hello,,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following challenge that I hope you can help me with:&lt;/P&gt;&lt;P&gt;In table "Orders" I have:&lt;/P&gt;&lt;P&gt;- customer ID&lt;BR /&gt;- product ID&lt;BR /&gt;- order date (dates from 1-1-2019 to 1-3-2021)&lt;BR /&gt;- quantity&lt;BR /&gt;- amount&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the table "COSTPRICES" I have at least 3 different cost prices for each Product ID depending on the date.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Row 1 the cost price from 1-1-2019 to 1-11-2019;&lt;/P&gt;&lt;P&gt;Row 2 is the costprice from 11/2/2019 to 7/6/2020 and&lt;/P&gt;&lt;P&gt;Row 3 is the costprice from 6/7/2020 until now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The column headings are:&lt;BR /&gt;- product ID&lt;BR /&gt;- start date&lt;BR /&gt;- end date&lt;BR /&gt;- cost price&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NB: There's also a calendar table in the PBIX&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to get the correct cost price per order from the cost price table and add it to the order table. That has to be the unique cost price that belongs to the order date and that must match just one of the 3 periods in which this cost price is determined. The LOOKUPVALUE function is obviously not an option, as it does not reference a unique value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the best approach to this question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;BR /&gt;Hans&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 17:24:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707457#M35234</guid>
      <dc:creator>Brandaris</dc:creator>
      <dc:date>2021-03-07T17:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up the correct value from a table with values per periods, based on a unique date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707561#M35239</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="216811" data-lia-user-login="Brandaris" class="lia-mention lia-mention-user"&gt;Brandaris&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a calculated column in the Orders table:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Price =
CALCULATE (
    DISTINCT ( CostPrices[Cost price] ),
    FILTER (
        ALL ( CostPrices[product ID], CostPrices[start date], CostPrices[end date] ),
        CostPrices[product ID] = Orders[product ID]
            &amp;amp;&amp;amp; CostPrices[start date] &amp;lt;= Orders[date]
            &amp;amp;&amp;amp; CostPrices[end date] &amp;gt; Orders[date]
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 100px; width: 100%; border-collapse: collapse; border-style: groove; border-color: #0c1c49; background-color: #00675f;" border="0" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15px;"&gt;
&lt;TD width="15.961305925030231%" style="width: 92px; height: 15px;"&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="84.03869407496977%" style="width: 485px; height: 15px; text-align: left;"&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Please accept the solution when done and consider &lt;FONT color="#FF9900"&gt;giving a thumbs up if posts are helpful.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT color="#FFFFFF"&gt;&lt;SPAN style="color: #ffffff;"&gt;&amp;nbsp;&lt;/SPAN&gt; &lt;/FONT&gt;&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="4.5" color="#FF99CC"&gt;Contact me privately for support with any larger-scale BI needs, tutoring, etc.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 22:27:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707561#M35239</guid>
      <dc:creator>AlB</dc:creator>
      <dc:date>2021-03-07T22:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking up the correct value from a table with values per periods, based on a unique date</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707612#M35241</link>
      <description>&lt;P&gt;Dear AIB,&lt;/P&gt;&lt;P&gt;Thank you very much for your quick and super good solution!&lt;/P&gt;&lt;P&gt;To let this solution work correctly, there must be no relationship between the calendar table and the cost price table (containing 2 date columns). Between the order table (with 1 date column) and the calendar table, of course, and fortunately yes ;-).&lt;/P&gt;&lt;P&gt;Instead of the DISTINCT function, I also tried the VALUES function. That works well too.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 00:05:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Looking-up-the-correct-value-from-a-table-with-values-per/m-p/1707612#M35241</guid>
      <dc:creator>Brandaris</dc:creator>
      <dc:date>2021-03-08T00:05:11Z</dc:date>
    </item>
  </channel>
</rss>

