<?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: Compare two rows and return the one with the earliest date Power Bi in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2941541#M97184</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="469512" data-lia-user-login="MikiMihaela27" class="lia-mention lia-mention-user"&gt;MikiMihaela27&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please create following column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
var min_date = MINX(FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])),[Status Date])
var max_date = MAXX(FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])),[Status Date])
var count_status = CALCULATE(COUNT('Table'[Status]),FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])))
return
SWITCH(
    TRUE(),
    'Table'[Status Date] = min_date &amp;amp;&amp;amp; count_status = 2, "include",
    'Table'[Status Date] = max_date &amp;amp;&amp;amp; count_status = 2, "exclude"
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this is the result you want:&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;Yadong Fang&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Dec 2022 09:40:11 GMT</pubDate>
    <dc:creator>v-yadongf-msft</dc:creator>
    <dc:date>2022-12-01T09:40:11Z</dc:date>
    <item>
      <title>Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936206#M96784</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table called "Jira tickets", in which I have multiple rows for the same ticket, as you can see below in the sample data:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we take for example Ticket 1, how can I compare the rows to take only the first Sprint when this ticket was in status "Done", based on the Status date? In this case, to have a calculated column that will say "include" for Sprint 7 (08-Sep-22) and "exclude" for Sprint 8 (04-Oct-22). I will have to do the same thing for the status "To Do".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 14:51:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936206#M96784</guid>
      <dc:creator>MikiMihaela27</dc:creator>
      <dc:date>2022-11-29T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936358#M96811</link>
      <description>&lt;P&gt;how to handle the status of In Progress?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 15:48:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936358#M96811</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-11-29T15:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936492#M96833</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="469512" data-lia-user-login="MikiMihaela27" class="lia-mention lia-mention-user"&gt;MikiMihaela27&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Include/Exclude =
VAR CurrentStatus = 'Jira tickets'[Status]
VAR CurrentDate = 'Jira tickets'[Status Date]
VAR CurrentKeyTable =
    CALCULATETABLE (
        'Jira tickets',
        ALLEXCEPT ( 'Jira tickets', 'Jira tickets'[Key] )
    )
VAR FilteredTable =
    FILTER ( CurrentKeyTable, 'Jira tickets'[Status] = "Done" )
VAR FirstDone =
    MINX ( FilteredTable, 'Jira tickets'[Status Date] )
RETURN
    IF (
        CurrentStatus = "Done",
        IF ( CurrentDate = FirstDone, "Include", "Exclude" )
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 29 Nov 2022 17:10:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2936492#M96833</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-11-29T17:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2937477#M96903</link>
      <description>&lt;P&gt;i tried, but unable to reach the last step, &lt;STRONG&gt;check if a row exists in another intermediate table&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code for the intermediate table physically :&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Table = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;table1&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;JiraTickets&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;JiraTickets&lt;/SPAN&gt;&lt;SPAN&gt;[Key]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;JiraTickets&lt;/SPAN&gt;&lt;SPAN&gt;[Status]&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&gt; &lt;SPAN&gt;table2&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&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; &lt;/SPAN&gt;&lt;SPAN&gt;table1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"MinDate"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;JiraTickets&lt;/SPAN&gt;&lt;SPAN&gt;[StatusDate]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;Table2&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Nov 2022 04:14:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2937477#M96903</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-11-30T04:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2941541#M97184</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="469512" data-lia-user-login="MikiMihaela27" class="lia-mention lia-mention-user"&gt;MikiMihaela27&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please create following column:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
var min_date = MINX(FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])),[Status Date])
var max_date = MAXX(FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])),[Status Date])
var count_status = CALCULATE(COUNT('Table'[Status]),FILTER('Table','Table'[Key] = EARLIER('Table'[Key]) &amp;amp;&amp;amp; 'Table'[Status] = EARLIER('Table'[Status])))
return
SWITCH(
    TRUE(),
    'Table'[Status Date] = min_date &amp;amp;&amp;amp; count_status = 2, "include",
    'Table'[Status Date] = max_date &amp;amp;&amp;amp; count_status = 2, "exclude"
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this is the result you want:&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;Yadong Fang&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 09:40:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2941541#M97184</guid>
      <dc:creator>v-yadongf-msft</dc:creator>
      <dc:date>2022-12-01T09:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two rows and return the one with the earliest date Power Bi</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2944282#M97355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your message! It really helped me a lot! In fact, I adjusted a bit the logic to display "include/exclude" for both 'To Do' and 'Done' statuses:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IncludevsExclude =&lt;BR /&gt;VAR CurrentStatus = 'Jira tickets'[Status]&lt;BR /&gt;VAR CurrentDate = 'Jira tickets'['Jira tickets' Status Date]&lt;BR /&gt;VAR CurrentKeyTable =&lt;BR /&gt;CALCULATETABLE (&lt;BR /&gt;'Jira tickets',&lt;BR /&gt;ALLEXCEPT ( 'Jira tickets', 'Jira tickets'[Key])&lt;BR /&gt;)&lt;BR /&gt;VAR FilteredTableDone =&lt;BR /&gt;FILTER ( CurrentKeyTable, 'Jira tickets'[Status] = "Done" )&lt;BR /&gt;VAR FilteredTableToDo =&lt;BR /&gt;FILTER ( CurrentKeyTable, 'Jira tickets'[Status] = "To Do" )&lt;BR /&gt;VAR FirstDone =&lt;BR /&gt;MINX ( FilteredTableDone, 'Jira tickets' [Status Date])&lt;BR /&gt;VAR FirstToDo =&lt;BR /&gt;MINX ( FilteredTableToDo, 'Jira tickets' [Status Date])&lt;BR /&gt;RETURN&lt;BR /&gt;IF (&lt;BR /&gt;CurrentStatus = "Done",&lt;BR /&gt;IF ( CurrentDate = FirstDone, "Include", "Exclude" ),&lt;BR /&gt;IF(&lt;BR /&gt;CurrentStatus = "To Do",&lt;BR /&gt;IF ( CurrentDate = FirstToDo, "Include", "Exclude" )&lt;BR /&gt;))&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 10:06:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Compare-two-rows-and-return-the-one-with-the-earliest-date-Power/m-p/2944282#M97355</guid>
      <dc:creator>MikiMihaela27</dc:creator>
      <dc:date>2022-12-02T10:06:23Z</dc:date>
    </item>
  </channel>
</rss>

