<?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: Using dax to get latest value from another table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2442622#M65463</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can create a &lt;STRONG&gt;calculated column&lt;/STRONG&gt; as below in table A, please find the details in &lt;EM&gt;&lt;STRONG&gt;the attachment&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;Quote_Sub = &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _acnum = 'A'[CASE NUMBER]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _maxdate =&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;CALCULATE ( MAX ( 'B'[Created] ), FILTER ( 'B', 'B'[CASE NUMBER] = _acnum ) )&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _count =&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;CALCULATE (&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;DISTINCTCOUNT ( 'B'[VALUE] ),&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;FILTER (&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;'B',&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;'B'[CASE NUMBER] = _acnum&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; 'B'[VALUE]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;IN { "Quote Approved", "Quote Sent" }&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; 'B'[Created] = _maxdate&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;RETURN&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;IF ( _count = 2, "Quote Approved", 'A'[Value] )&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the above one is not your expected one, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;(exclude sensitive data) in the table A and B with &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt; &lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;I&gt;with&lt;/I&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;backend logic and special examples&lt;/STRONG&gt;. It is better if you can share a simplified&amp;nbsp;pbix file with me.&amp;nbsp;You can refer the following thread to upload your file in the community.&amp;nbsp;Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=05%7C01%7Cv-yiruan%40microsoft.com%7C28e2e2c43e714d936a5708da1798d8d5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637848242638751089%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&amp;amp;sdata=7Je7sdNHpbKh15hbgZ%2Be39frXexC7TxxAaQDRI8QbX4%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Apr 2022 07:53:51 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-04-07T07:53:51Z</dc:date>
    <item>
      <title>Using dax to get latest value from another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434367#M64930</link>
      <description>&lt;P&gt;I'd like to update table A with values from Table B.&lt;BR /&gt;Requirement - to update the latest [Value] based on [Created] where [value] contains 'Quote'.&lt;BR /&gt;Catch is, if on the same date quote is sent and approved, then table A needs to be updated with Quote Approved. What is the best way to get the desired outcome.&lt;/P&gt;&lt;LI-CODE lang="php"&gt;Quote_Sub = 
VAR CaseNumber = 'A'[CASE NUMBER]
VAR SUB_Table =
    CALCULATETABLE (
        SELECTCOLUMNS (
            FILTER ( B, B[Case Number] = CaseNumber ),
            "Start Date", B[Created],
            "Sub Value", B[Value]
        ),
        CONTAINSSTRING ( DCM_METRIC_INSTANCE[Value], "Quote" )
    )
VAR Quote_A = MAXX(FILTER(SUB_Table, [Sub Value] = "Quote Approved"),[Start Date])
VAR Quote_Ex = MAXX(FILTER(SUB_Table, [Sub Value] = "Quote Expired"),[Start Date])
VAR Quote_R = MAXX(FILTER(SUB_Table, [Sub Value] = "Quote Rejected"),[Start Date])
VAR Quote_Es = MAXX(FILTER(SUB_Table, [Sub Value] = "Quote Escalated"),[Start Date])
VAR Quote_S = MAXX(FILTER(SUB_Table, [Sub Value] = "Quote Sent"),[Start Date])

VAR max_date = MAXX({Quote_A,Quote_Ex,Quote_R,Quote_Es,Quote_S}, [Value])
VAR max_value = 
calculatetable(
    FIRSTNONBLANK(SELECTCOLUMNS( FILTER(SUB_Table,[Start Date]=max_date),
"max Value",[Sub Value]),[max Value])
)
return max_value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 05:09:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434367#M64930</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-04T05:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using dax to get latest value from another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434463#M64936</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , Is there a preference when date is the same &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example measure&lt;/P&gt;
&lt;P&gt;new column = &lt;BR /&gt;var _max = maxx(filter(Table, [casenumber] = earlier([casenumber]) ), [Created])&lt;BR /&gt;return &lt;BR /&gt;maxx(filter(Table, [casenumber] = earlier([casenumber]) &amp;amp;&amp;amp; [Created] = _max), [Value])&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 06:00:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434463#M64936</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-04-04T06:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using dax to get latest value from another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434523#M64938</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for your response. Yes the preference is Quote sent gets the least preference, since after the quote is sent, it can be rejected, accepted, escalated or expired on the same day. And it is not always necessary that there will be a subsequent event for a casenumber. In such scenario the atest stage would be quote sent.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 06:16:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2434523#M64938</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-04T06:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using dax to get latest value from another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2442622#M65463</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;You can create a &lt;STRONG&gt;calculated column&lt;/STRONG&gt; as below in table A, please find the details in &lt;EM&gt;&lt;STRONG&gt;the attachment&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;Quote_Sub = &lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _acnum = 'A'[CASE NUMBER]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _maxdate =&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;CALCULATE ( MAX ( 'B'[Created] ), FILTER ( 'B', 'B'[CASE NUMBER] = _acnum ) )&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;VAR _count =&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;CALCULATE (&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;DISTINCTCOUNT ( 'B'[VALUE] ),&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;FILTER (&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;'B',&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;'B'[CASE NUMBER] = _acnum&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; 'B'[VALUE]&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;IN { "Quote Approved", "Quote Sent" }&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;amp;&amp;amp; 'B'[Created] = _maxdate&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;RETURN&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;STRONG&gt;IF ( _count = 2, "Quote Approved", 'A'[Value] )&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the above one is not your expected one, please provide some&amp;nbsp;&lt;STRONG&gt;sample data&lt;/STRONG&gt;&amp;nbsp;(exclude sensitive data) in the table A and B with &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text&lt;/STRONG&gt; &lt;/FONT&gt;format and your&amp;nbsp;&lt;STRONG&gt;expected result&lt;I&gt;with&lt;/I&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;backend logic and special examples&lt;/STRONG&gt;. It is better if you can share a simplified&amp;nbsp;pbix file with me.&amp;nbsp;You can refer the following thread to upload your file in the community.&amp;nbsp;Thank you.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FDesktop%2FHow-to-upload-PBI-in-Community%2Fm-p%2F1672886&amp;amp;data=05%7C01%7Cv-yiruan%40microsoft.com%7C28e2e2c43e714d936a5708da1798d8d5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637848242638751089%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&amp;amp;sdata=7Je7sdNHpbKh15hbgZ%2Be39frXexC7TxxAaQDRI8QbX4%3D&amp;amp;reserved=0" target="_blank" rel="noopener"&gt;How to upload PBI in Community&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 07:53:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-dax-to-get-latest-value-from-another-table/m-p/2442622#M65463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-04-07T07:53:51Z</dc:date>
    </item>
  </channel>
</rss>

