<?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 Create End Date using Start Dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996517#M100993</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table in Power BI like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ID  START_DATE 
1   06/24/2016
1   06/24/2017
1   06/24/2018
2   08/08/2017
2   08/08/2016
3   12/12/2015&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a calculated column using DAX, in which I have to calculate the End Date for each record and leave blank if it is MAX Start Date. Output should look as in the example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ID  START_DATE  END_DATE
1   06/24/2016  06/23/2017
1   06/24/2017  06/23/2018
1   06/24/2018  
2   08/08/2017  
2   08/08/2016  08/07/2017
3   12/12/2015  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I'm stuck with this solution where I can have MAX End Date for all of the historical records but it's not what I need:&amp;nbsp;&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;End Date = 
VAR TableKey = 'Table1'[ItemKey]
VAR CountDuplicates =
    CALCULATE (
        COUNTROWS ( 'Table1' ),
        ALL ( 'Table1' ),
        'Table1'[ItemKey] = TableKey
    )
VAR GetEndDate =
    CALCULATE (
        MAX ( 'Table1'[Start_Date] ),
        FILTER (
            'Table1',
            'Table1'[ItemKey] = EARLIER ( 'Table1'[ItemKey] )
        )
    )
RETURN
    IF (
        AND (
            CountDuplicates &amp;gt; 1,
            GetEndDate &amp;lt;&amp;gt; 'Table1'[Start_Date]
        ),
        GetEndDate - 1,
        BLANK ()
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please support how to get desired result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Mon, 02 Jan 2023 09:26:01 GMT</pubDate>
    <dc:creator>LadyPeshet</dc:creator>
    <dc:date>2023-01-02T09:26:01Z</dc:date>
    <item>
      <title>Create End Date using Start Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996517#M100993</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table in Power BI like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ID  START_DATE 
1   06/24/2016
1   06/24/2017
1   06/24/2018
2   08/08/2017
2   08/08/2016
3   12/12/2015&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a calculated column using DAX, in which I have to calculate the End Date for each record and leave blank if it is MAX Start Date. Output should look as in the example below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ID  START_DATE  END_DATE
1   06/24/2016  06/23/2017
1   06/24/2017  06/23/2018
1   06/24/2018  
2   08/08/2017  
2   08/08/2016  08/07/2017
3   12/12/2015  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I'm stuck with this solution where I can have MAX End Date for all of the historical records but it's not what I need:&amp;nbsp;&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;End Date = 
VAR TableKey = 'Table1'[ItemKey]
VAR CountDuplicates =
    CALCULATE (
        COUNTROWS ( 'Table1' ),
        ALL ( 'Table1' ),
        'Table1'[ItemKey] = TableKey
    )
VAR GetEndDate =
    CALCULATE (
        MAX ( 'Table1'[Start_Date] ),
        FILTER (
            'Table1',
            'Table1'[ItemKey] = EARLIER ( 'Table1'[ItemKey] )
        )
    )
RETURN
    IF (
        AND (
            CountDuplicates &amp;gt; 1,
            GetEndDate &amp;lt;&amp;gt; 'Table1'[Start_Date]
        ),
        GetEndDate - 1,
        BLANK ()
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please support how to get desired result?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 09:26:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996517#M100993</guid>
      <dc:creator>LadyPeshet</dc:creator>
      <dc:date>2023-01-02T09:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create End Date using Start Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996591#M100998</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="493134" data-lia-user-login="LadyPeshet" class="lia-mention lia-mention-user"&gt;LadyPeshet&lt;/a&gt; , Create a new column like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;end date =&lt;/P&gt;
&lt;P&gt;Var _min = Minx(filter( table, [ID] = earlier([ID]) &amp;amp;&amp;amp; [Start Date] &amp;gt; earlier([Start Date]) ), [Start Date])&lt;/P&gt;
&lt;P&gt;return&lt;/P&gt;
&lt;P&gt;if(isblank(_min), blank(), _min-1)&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 10:17:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996591#M100998</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2023-01-02T10:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create End Date using Start Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996594#M100999</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="493134" data-lia-user-login="LadyPeshet" class="lia-mention lia-mention-user"&gt;LadyPeshet&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;END_DATE =
MINX (
    FILTER (
        CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
        'Table'[START_DATE] &amp;gt; EARLIER ( 'Table'[START_DATE] )
    ),
    'Table'[START_DATE]
) - 1&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;</description>
      <pubDate>Mon, 02 Jan 2023 10:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-End-Date-using-Start-Dates/m-p/2996594#M100999</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-01-02T10:44:18Z</dc:date>
    </item>
  </channel>
</rss>

