<?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: DAX Lookup value in the same table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3444122#M130910</link>
    <description>&lt;P&gt;&lt;SPAN&gt;It looks like you want to assign the "Assignee" value to each row in your table based on certain conditions. To achieve this, you can use DAX measures and a combination of functions to perform the lookup and assignment. Here's a modified version of your DAX code to achieve the desired result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Assigned =&lt;BR /&gt;VAR Key =&lt;BR /&gt;Table[ID]&lt;BR /&gt;VAR LatestStatusDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Table[EndDate]),&lt;BR /&gt;FILTER(Table, Table[ID] = Key)&lt;BR /&gt;)&lt;BR /&gt;VAR LatestAssignee =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Table[Assignee]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Table,&lt;BR /&gt;Table[ID] = Key &amp;amp;&amp;amp;&lt;BR /&gt;Table[AssigneeEndDate] &amp;lt;= LatestStatusDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;LatestAssignee&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code should assign the appropriate "Assignee" value to each row based on the conditions you specified. The key points in this code are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We use a VAR statement to define the "Key" and "LatestStatusDate" variables.&lt;/LI&gt;&lt;LI&gt;For "Key," we simply reference the "ID" column from the table.&lt;/LI&gt;&lt;LI&gt;For "LatestStatusDate," we use the CALCULATE function with a FILTER condition to find the maximum "EndDate" value for rows where the "ID" matches the current row's "ID."&lt;/LI&gt;&lt;LI&gt;In the "LatestAssignee" variable, we use CALCULATE with another FILTER condition to find the maximum "Assignee" value for rows where the "ID" matches the current row's "ID" and the "AssigneeEndDate" is less than or equal to the "LatestStatusDate."&lt;/LI&gt;&lt;LI&gt;Finally, we return the "LatestAssignee" value, which will be assigned to each row in your table.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;When you use this measure in your table, it should give you the desired result, as shown in your "Result" section.&lt;/P&gt;</description>
    <pubDate>Sat, 23 Sep 2023 08:17:00 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2023-09-23T08:17:00Z</dc:date>
    <item>
      <title>DAX Lookup value in the same table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3443895#M130897</link>
      <description>&lt;P&gt;Hi, I tried lookupvalue and calculate but can't get the result I need.&amp;nbsp; Any help is appreciated.&amp;nbsp; Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Assigned = CALCULATE(FIRSTNONBLANK(Table[Assignee],1),FILTER(ALL(Table[Assignee]),Table[EndDate]=Table[AssigneeEndDate]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Assigned =&lt;BR /&gt;VAR Key =&lt;BR /&gt;MIN(Table[ID])&lt;BR /&gt;VAR LatestStatusDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Table[EndDate]),&lt;BR /&gt;Table[ID] = Key&lt;BR /&gt;)&lt;BR /&gt;VAR LatestAssignee =&lt;BR /&gt;LOOKUPVALUE(&lt;BR /&gt;Table[Assignee],&lt;BR /&gt;Table[Key], Key,&lt;BR /&gt;Table[AssigneeEndDate], LatestStatusDate&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;LatestAssignee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;StartDate&lt;/TD&gt;&lt;TD&gt;EndDate&lt;/TD&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;TD&gt;AssigneeEndDate&lt;/TD&gt;&lt;TD&gt;Assignee&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/1/2023&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;9/3/2023&amp;nbsp;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/4/2023&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;9/5/2023&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;In Progress&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/6/2023&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;Complete&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;9/1/2023&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;9/3/2023&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;9/5/2023&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF0000"&gt;null&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Result&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;StartDate&lt;/TD&gt;&lt;TD&gt;EndDate&lt;/TD&gt;&lt;TD&gt;Status&lt;/TD&gt;&lt;TD&gt;Assignee&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/1/2023&lt;/TD&gt;&lt;TD&gt;9/3/2023&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Start&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/4/2023&lt;/TD&gt;&lt;TD&gt;9/5/2023&lt;/TD&gt;&lt;TD&gt;In Progress&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9/6/2023&lt;/TD&gt;&lt;TD&gt;null&lt;/TD&gt;&lt;TD&gt;Complete&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 23:49:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3443895#M130897</guid>
      <dc:creator>AC2023</dc:creator>
      <dc:date>2023-09-22T23:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Lookup value in the same table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3444122#M130910</link>
      <description>&lt;P&gt;&lt;SPAN&gt;It looks like you want to assign the "Assignee" value to each row in your table based on certain conditions. To achieve this, you can use DAX measures and a combination of functions to perform the lookup and assignment. Here's a modified version of your DAX code to achieve the desired result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Assigned =&lt;BR /&gt;VAR Key =&lt;BR /&gt;Table[ID]&lt;BR /&gt;VAR LatestStatusDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Table[EndDate]),&lt;BR /&gt;FILTER(Table, Table[ID] = Key)&lt;BR /&gt;)&lt;BR /&gt;VAR LatestAssignee =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Table[Assignee]),&lt;BR /&gt;FILTER(&lt;BR /&gt;Table,&lt;BR /&gt;Table[ID] = Key &amp;amp;&amp;amp;&lt;BR /&gt;Table[AssigneeEndDate] &amp;lt;= LatestStatusDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;LatestAssignee&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code should assign the appropriate "Assignee" value to each row based on the conditions you specified. The key points in this code are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;We use a VAR statement to define the "Key" and "LatestStatusDate" variables.&lt;/LI&gt;&lt;LI&gt;For "Key," we simply reference the "ID" column from the table.&lt;/LI&gt;&lt;LI&gt;For "LatestStatusDate," we use the CALCULATE function with a FILTER condition to find the maximum "EndDate" value for rows where the "ID" matches the current row's "ID."&lt;/LI&gt;&lt;LI&gt;In the "LatestAssignee" variable, we use CALCULATE with another FILTER condition to find the maximum "Assignee" value for rows where the "ID" matches the current row's "ID" and the "AssigneeEndDate" is less than or equal to the "LatestStatusDate."&lt;/LI&gt;&lt;LI&gt;Finally, we return the "LatestAssignee" value, which will be assigned to each row in your table.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;When you use this measure in your table, it should give you the desired result, as shown in your "Result" section.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Sep 2023 08:17:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3444122#M130910</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-09-23T08:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Lookup value in the same table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3446568#M131149</link>
      <description>&lt;P&gt;Thank you for the DAX code, but it's not returing the desired result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This problem can&amp;nbsp; easily done in SQL query using self left join.&lt;/P&gt;&lt;P&gt;Here's SQL query, the 1st select is the data from the table, the 2nd select is the correct desired result:&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Note that in this sample data,&amp;nbsp; I added the Type field to make it easy to get the correct result.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is the result in Power BI:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;DAX for Assigned:&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;I get the same result whether I've the extra filter on TempTable[Type] or not.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2023 19:11:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3446568#M131149</guid>
      <dc:creator>AC2023</dc:creator>
      <dc:date>2023-09-25T19:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Lookup value in the same table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3447275#M131205</link>
      <description>&lt;P&gt;Hi&amp;nbsp; &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="621407" data-lia-user-login="AC2023" class="lia-mention lia-mention-user"&gt;AC2023&lt;/a&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;Here are the steps you can follow：&lt;/P&gt;
&lt;P&gt;1. Create measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure =
MAXX(
    FILTER(ALL('Table'),
    'Table'[EndDate] in SELECTCOLUMNS('Table',"1",[AssigneeEndDate])),[StartDate])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Measure 2 =
MAXX(
    FILTER(ALL('Table'),
    [Measure]=MAX('Table'[StartDate])),[Assignee])&lt;/LI-CODE&gt;
&lt;P&gt;2. Result:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Liu Yang&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;Accept it as the solution&lt;/EM&gt; to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 07:32:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3447275#M131205</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-09-26T07:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Lookup value in the same table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3448060#M131261</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp; This works great with the sample data I provided, and it gives the correct desired result.&amp;nbsp; However, when I applied this to my actual table which is huge, I got the error message "Resources Exceeded.&amp;nbsp; This visual has exceeded the available resources.&amp;nbsp; Try filtering to decrease the amount of data displayed."&amp;nbsp; Any ideas how to fix this error?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 15:03:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Lookup-value-in-the-same-table/m-p/3448060#M131261</guid>
      <dc:creator>AC2023</dc:creator>
      <dc:date>2023-09-26T15:03:00Z</dc:date>
    </item>
  </channel>
</rss>

