<?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: Help adding a column that looks up the earliest event in another table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2304677#M57016</link>
    <description>&lt;P&gt;Thank you, that is crystal clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the original suggestion from another user was this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Lable = 
CALCULATE (
    MAX ( 'Table 2'[LABEL] ),
    FILTER (
        'Table 2',
        'Table 1'[ID2] = EARLIER ( 'Table 1'[ID2] )
            &amp;amp;&amp;amp; 'Table 2'[DATE]
                = CALCULATE (
                    MIN ( 'Table 2'[DATE] ),
                    FILTER ( ALL ( 'Table 2' ), 'Table 2'[ID2] = EARLIER ( 'Table 1'[ID2] ) )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could only get it to work by using&amp;nbsp;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;Table 2&lt;/FONT&gt;&lt;SPAN&gt;'[ID2] = 'Table 1'[ID2] in line 6. I get that the two filters are doing two different things (though applied slightly differently than you have above). But I do not understand why the proposal worked for the other user and not for me. Whereas my slight tweak (which makes more sense to me) seems to work perfectly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jan 2022 08:53:55 GMT</pubDate>
    <dc:creator>MJEnnis</dc:creator>
    <dc:date>2022-01-27T08:53:55Z</dc:date>
    <item>
      <title>Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2292158#M56381</link>
      <description>&lt;P&gt;Can anyone see what I am doing wrong here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a column in Table 1 that looks up the earliest occurence of an event in Table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are simplified versions of the tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 1&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID1&lt;/TD&gt;&lt;TD&gt;ID2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;5435&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1003&lt;/TD&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1004&lt;/TD&gt;&lt;TD&gt;4025&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 2&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID2&lt;/TD&gt;&lt;TD&gt;LABEL&lt;/TD&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;11/11/2018&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5435&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;TD&gt;02/05/2017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;TD&gt;01/25/2020&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4025&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;06/22/2019&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5435&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;05/30/2020&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The resulting table should look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID1&lt;/TD&gt;&lt;TD&gt;ID2&lt;/TD&gt;&lt;TD&gt;LABEL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1001&lt;/TD&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1002&lt;/TD&gt;&lt;TD&gt;5435&lt;/TD&gt;&lt;TD&gt;Blue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1003&lt;/TD&gt;&lt;TD&gt;8842&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1004&lt;/TD&gt;&lt;TD&gt;4025&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried something this, to no avail:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Column = CALCULATE(&lt;/SPAN&gt;&lt;SPAN&gt;VALUES(&lt;/SPAN&gt;&lt;SPAN&gt;'Table 2'[LABEL]),&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;FILTER(&lt;/SPAN&gt;&lt;SPAN&gt;'Table 2',&lt;/SPAN&gt;&lt;SPAN&gt;'Table 2'[ID2] = 'Table 1'[ID2]&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; 'Table 2'[Date] = MINX(&lt;/SPAN&gt;&lt;SPAN&gt;FILTER(&lt;/SPAN&gt;&lt;SPAN&gt;'Table 2',&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Table 2'[ID2] = Earlier(&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Table 2'[ID2])),&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Table 2'[Date]))&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 22:34:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2292158#M56381</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-19T22:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2292193#M56384</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225395" data-lia-user-login="MJEnnis" class="lia-mention lia-mention-user"&gt;MJEnnis&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this code to add a new column:&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Lable = 
CALCULATE (
    MAX ( 'Table 2'[LABEL] ),
    FILTER (
        'Table 2',
        'Table 1'[ID2] = EARLIER ( 'Table 1'[ID2] )
            &amp;amp;&amp;amp; 'Table 2'[DATE]
                = CALCULATE (
                    MIN ( 'Table 2'[DATE] ),
                    FILTER ( ALL ( 'Table 2' ), 'Table 2'[ID2] = EARLIER ( 'Table 1'[ID2] ) )
                )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output:&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;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;helps&lt;/SPAN&gt;&lt;/STRONG&gt;, please consider&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;accepting&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;it as the solution&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN&gt;Appreciate your Kudos!!&lt;BR /&gt;&lt;STRONG&gt;LinkedIn:&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;A href="https://www.linkedin.com/in/vahid-dm/" target="_blank"&gt;www.linkedin.com/in/vahid-dm/&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 22:57:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2292193#M56384</guid>
      <dc:creator>VahidDM</dc:creator>
      <dc:date>2022-01-19T22:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2293362#M56450</link>
      <description>&lt;P&gt;@&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2292193/highlight/true#M56384" target="_blank" rel="noopener"&gt;&lt;SPAN class="lia-message-in-response-to-username"&gt;VahidDM&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My database is pretty large, and when I run this code, I get an insufficient memory error. However, I got it to load with a seemingly minor adjustment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Before I trust the results with the adjustment, but also for my own understanding, I have a couple questions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I had tried using CALCULATE(MIN(), FILTER()) instead of a MINX() function on my original code but it did not work. So&amp;nbsp;&lt;/SPAN&gt;it seems that the big difference between what I had originally tried and what you propose is that you have replaced VALUES() with MAX() in line 3. Why does MAX() work and not VALUES()? Just trying to understand the syntax there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, the timeout error happens when I use&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'Table 1'[ID2] = EARLIER('Table 1'[ID2])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it does not happen when I use:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'Table 2'[ID2] = 'Table 1'[ID2]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In other words, when I use your proposal, but just keep the original code in line 6, it loads quite quickly and appears to still produce the desired column. Maybe I do not fully understand how the EARLIER() function works... Why do you propose to index this filter on the "earlier" occurence of ID2 in Table 1 (since the code is already filtering Table 2 for the earliest date)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As said, I just want to make sure that the adaptation that is working for me is not giving me erroneous data and I want to understand the syntax, since I will need to recycle this code a couple times to finish my project.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks a lot!!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 20:50:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2293362#M56450</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-20T20:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2297927#M56664</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225395" data-lia-user-login="MJEnnis" class="lia-mention lia-mention-user"&gt;MJEnnis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why does MAX() work and not VALUES()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/dax/values-function-dax" target="_blank" rel="noopener"&gt;VALUES()&lt;/A&gt; will return a table. Please check its definition:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;When the input parameter is a column name, returns &lt;STRONG&gt;a one-column table&lt;/STRONG&gt; that contains the distinct values from the specified column. Duplicate values are removed and only unique values are returned. A BLANK value can be added. &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;When the input parameter is a table name, returns &lt;STRONG&gt;the rows from the specified table&lt;/STRONG&gt;. Duplicate rows are preserved. A BLANK row can be added.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In your scenario, the&amp;nbsp;end result is a single value and it can work fine. But if&amp;nbsp;the&amp;nbsp;end result with two values, an error will occur. It is recommended to use &lt;A href="https://docs.microsoft.com/dax/max-function-dax" target="_blank" rel="noopener"&gt;MAX()&lt;/A&gt;, &lt;A href="https://docs.microsoft.com/dax/min-function-dax" target="_blank" rel="noopener"&gt;MIN()&lt;/A&gt;, &lt;A href="https://docs.microsoft.com/dax/firstnonblank-function-dax" target="_blank" rel="noopener"&gt;FIRSTNONBLANK()&lt;/A&gt;, &lt;A href="https://docs.microsoft.com/dax/selectedvalue-function" target="_blank" rel="noopener"&gt;SELECTEDVALUE()&lt;/A&gt;, etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, you can refer to this document to get more details:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/dax/best-practices/dax-selectedvalue" target="_blank" rel="noopener"&gt;Use SELECTEDVALUE instead of VALUES in DAX - DAX | Microsoft Docs&lt;/A&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;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P class="1643006740273"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'Table 1'[ID2] = EARLIER('Table 1'[ID2])&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The &lt;A href="https://docs.microsoft.com/dax/earlier-function-dax" target="_blank" rel="noopener"&gt;EARLIER&lt;/A&gt; function is used to refer to the&amp;nbsp;&lt;STRONG&gt;'Table 1'[ID2]&lt;/STRONG&gt;&amp;nbsp;column value&amp;nbsp;&lt;EM&gt;in the current row context&lt;/EM&gt;. It&amp;nbsp;&lt;SPAN&gt;can be improved by using a &lt;A href="https://docs.microsoft.com/dax/var-dax" target="_blank" rel="noopener"&gt;variable&lt;/A&gt; instead of the EARLIER function, such as:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;VAR CurrentID2_ = 'Table 1'[ID2]&lt;/LI-CODE&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;SPAN&gt;For&amp;nbsp;best practices when using VAR, see&amp;nbsp;&lt;A href="https://docs.microsoft.com/dax/best-practices/dax-variables" target="_blank" rel="noopener" data-linktype="relative-path"&gt;Use variables to improve your DAX formulas&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, for the &lt;A href="https://docs.microsoft.com/dax/filter-function-dax" target="_blank" rel="noopener"&gt;FILTER()&lt;/A&gt; function,&amp;nbsp;it should only be used when necessary.&amp;nbsp;For best performance, it's recommended you use Boolean expressions as filter arguments, whenever possible.&amp;nbsp;For more details, please refer:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/dax/best-practices/dax-avoid-avoid-filter-as-filter-argument" target="_blank" rel="noopener"&gt;Avoid using FILTER as a filter argument in DAX - DAX | Microsoft Docs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://exceleratorbi.com.au/the-filter-function-in-dax/" target="_blank" rel="noopener"&gt;The FILTER Function in DAX - Excelerator BI&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://exceleratorbi.com.au/the-filter-function-in-dax-part-2/" target="_blank" rel="noopener"&gt;The FILTER Function in DAX Part 2 - Excelerator BI&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In view of the above, please&amp;nbsp;&lt;/SPAN&gt;check if this expression can give better computing performance in your scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Label 4 = 

//Store the current ID2.
VAR CurrentID2_ = 'Table 1'[ID2]

//Store the EarliestDate of the current ID2.
VAR EarliestDate_ =
    CALCULATE ( MIN ( 'Table 2'[DATE] ), 'Table 2'[ID2] = CurrentID2_ )

RETURN
//Return the corresponding LABEL of the EarliestDate_ of current ID2.
    CALCULATE (
        MAX ( 'Table 2'[LABEL] ),
        'Table 2'[DATE] = EarliestDate_,
        'Table 2'[ID2] = CurrentID2_  // Just in case there are the same EarliestDate_ among [ID2].
    )
&lt;/LI-CODE&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;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 07:20:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2297927#M56664</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2022-01-24T07:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2300762#M56822</link>
      <description>&lt;P&gt;Thanks, Icey, for the clarification on MAX() vs VALUE(). Also thanks for the recomendations on improving performance. Not all of them will work in my case, as this is all part of a much longer code for a calculated table. Cannot store VARs based on "table expressions" apparently. They have to be tables that already exist in the model, it seems. However, dropping the FILTER() commands could help, once the code is finished and just needs to be optimized.&amp;nbsp; My only remaining question:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Will this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'Table 1'[ID2] = EARLIER('Table 1'[ID2])&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;return the same as this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'Table 2'[ID2] = 'Table 1'[ID2]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;in this case?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 10:30:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2300762#M56822</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-25T10:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2302156#M56880</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225395" data-lia-user-login="MJEnnis" class="lia-mention lia-mention-user"&gt;MJEnnis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;My only remaining question:&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;Will this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'Table 1'[ID2] = EARLIER('Table 1'[ID2])&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;return the same as this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'Table 2'[ID2] = 'Table 1'[ID2]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;in this case?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The answer is NO. Please check:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;When you use&amp;nbsp;&lt;SPAN&gt;'&lt;FONT color="#FF0000"&gt;Table 1&lt;/FONT&gt;'[ID2] = EARLIER('Table 1'[ID2]), the filtered table is "&lt;FONT color="#FF0000"&gt;Table 1&lt;/FONT&gt;";&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When you use '&lt;FONT color="#FF0000"&gt;Table 2&lt;/FONT&gt;'[ID2] = 'Table 1'[ID2], the filtered table is "&lt;FONT color="#FF0000"&gt;Table 2&lt;/FONT&gt;".&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 02:33:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2302156#M56880</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2022-01-26T02:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2304677#M57016</link>
      <description>&lt;P&gt;Thank you, that is crystal clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the original suggestion from another user was this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Lable = 
CALCULATE (
    MAX ( 'Table 2'[LABEL] ),
    FILTER (
        'Table 2',
        'Table 1'[ID2] = EARLIER ( 'Table 1'[ID2] )
            &amp;amp;&amp;amp; 'Table 2'[DATE]
                = CALCULATE (
                    MIN ( 'Table 2'[DATE] ),
                    FILTER ( ALL ( 'Table 2' ), 'Table 2'[ID2] = EARLIER ( 'Table 1'[ID2] ) )&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could only get it to work by using&amp;nbsp;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;Table 2&lt;/FONT&gt;&lt;SPAN&gt;'[ID2] = 'Table 1'[ID2] in line 6. I get that the two filters are doing two different things (though applied slightly differently than you have above). But I do not understand why the proposal worked for the other user and not for me. Whereas my slight tweak (which makes more sense to me) seems to work perfectly.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 08:53:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2304677#M57016</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-27T08:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2304730#M57020</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="164362" data-lia-user-login="Icey" class="lia-mention lia-mention-user"&gt;Icey&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be clearer, this is what has worked for me, which is similar to what you propose (although I cannot store the variables you propose, because Table1 is not a table in the model, but a table expression in the larger code itself:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Label =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;MAX ( 'Table 2'[LABEL] ),&lt;BR /&gt;FILTER ( 'Table 2', &lt;FONT color="#FF0000"&gt;'Table 2'[ID2] =&amp;nbsp; 'Table 1'[ID2]&lt;/FONT&gt; )&lt;BR /&gt;&amp;amp;&amp;amp; 'Table 2'[DATE]&lt;BR /&gt;= CALCULATE (&lt;BR /&gt;MIN ( 'Table 2'[DATE] ),&lt;BR /&gt;FILTER ( ALL ( 'Table 2' ), 'Table 2'[ID2] = EARLIER (&lt;FONT color="#FF0000"&gt; 'Table 2'[ID2]&lt;/FONT&gt; ) )&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;My slight changes to the original proposal are in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;. The original proposal kept timing out before it would load. So I could never really test it out. After making the changes in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;, it seems to work. But I have over 30.000 rows, so I cannot confirm in every case. I just want to make sure that what I am doing works.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jan 2022 09:08:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2304730#M57020</guid>
      <dc:creator>MJEnnis</dc:creator>
      <dc:date>2022-01-27T09:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help adding a column that looks up the earliest event in another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2307115#M57186</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225395" data-lia-user-login="MJEnnis" class="lia-mention lia-mention-user"&gt;MJEnnis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="225395" data-lia-user-login="MJEnnis" class="lia-mention lia-mention-user"&gt;MJEnnis&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="164362" data-lia-user-login="Icey" class="lia-mention lia-mention-user"&gt;Icey&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be clearer, this is what has worked for me, which is similar to what you propose (although I cannot store the variables you propose, because Table1 is not a table in the model, but a table expression in the larger code itself:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Label =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;MAX ( 'Table 2'[LABEL] ),&lt;BR /&gt;FILTER ( 'Table 2', &lt;FONT color="#FF0000"&gt;'Table 2'[ID2] =&amp;nbsp; 'Table 1'[ID2]&lt;/FONT&gt; )&lt;BR /&gt;&amp;amp;&amp;amp; 'Table 2'[DATE]&lt;BR /&gt;= CALCULATE (&lt;BR /&gt;MIN ( 'Table 2'[DATE] ),&lt;BR /&gt;FILTER ( ALL ( 'Table 2' ), 'Table 2'[ID2] = EARLIER (&lt;FONT color="#FF0000"&gt; 'Table 2'[ID2]&lt;/FONT&gt; ) )&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;My slight changes to the original proposal are in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;. The original proposal kept timing out before it would load. So I could never really test it out. After making the changes in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;, it seems to work. But I have over 30.000 rows, so I cannot confirm in every case. I just want to make sure that what I am doing works.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Based on your description and my experience and test, your expression will work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Icey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 08:07:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Help-adding-a-column-that-looks-up-the-earliest-event-in-another/m-p/2307115#M57186</guid>
      <dc:creator>Icey</dc:creator>
      <dc:date>2022-01-28T08:07:49Z</dc:date>
    </item>
  </channel>
</rss>

