<?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: Wanted to know the maximum date from list of dates if there is gap based on Unique ID in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278158#M121691</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="573889" data-lia-user-login="Gayathri1992" class="lia-mention lia-mention-user"&gt;Gayathri1992&lt;/a&gt;&amp;nbsp;That's not a particularly easy problem to solve. You could potentially use something like Cthulhu to find the gaps and then proceed from there.&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211" target="_blank"&gt;Cthulhu - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 13:57:26 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2023-06-11T13:57:26Z</dc:date>
    <item>
      <title>Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278148#M121688</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to Power bi and i wanted an help in getting the maximum date based on conditions. Below is my requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have list of unique ID's for which there are reported dates as well, however for few ID's there might me gap in the dates because they would have appeared today and later may be again in another date they would have appeared. So i wanted to know the Max date for unique id based on gap in date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example ABC has appeared on 11/06/2023 and 12/06/2023 and again on 20/06/2023 then my maximum date for ABC should show for 12/06/2023 and 20/06/2023&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;Unique ID&lt;/TD&gt;&lt;TD&gt;Reported Date&lt;/TD&gt;&lt;TD&gt;Max Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;11/06/2023&lt;/TD&gt;&lt;TD&gt;12/06/2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;12/06/2023&lt;/TD&gt;&lt;TD&gt;12/06/2023&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;20/06/2023&lt;/TD&gt;&lt;TD&gt;20/06/2023&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 13:16:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278148#M121688</guid>
      <dc:creator>Gayathri1992</dc:creator>
      <dc:date>2023-06-11T13:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278158#M121691</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="573889" data-lia-user-login="Gayathri1992" class="lia-mention lia-mention-user"&gt;Gayathri1992&lt;/a&gt;&amp;nbsp;That's not a particularly easy problem to solve. You could potentially use something like Cthulhu to find the gaps and then proceed from there.&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211" target="_blank"&gt;Cthulhu - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 13:57:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278158#M121691</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-06-11T13:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278160#M121693</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="573889" data-lia-user-login="Gayathri1992" class="lia-mention lia-mention-user"&gt;Gayathri1992&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt; &amp;nbsp;this is pretty complicated. I tried to produce a solution for this but not sure if it works &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt; I currently don't have access to my laptop to test it but I appreciate if you would be able to test from your end.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Calculated Column solution:&lt;/P&gt;
&lt;P&gt;Max Date =&lt;BR /&gt;VAR CurrentReportDate = 'Table'[Report Date]&lt;BR /&gt;VAR CurrentIDTable =&lt;BR /&gt;CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Unique ID] ) )&lt;BR /&gt;VAR TableOnAndAfter =&lt;BR /&gt;FILTER ( CurrentIDTable, 'Table'[Report Date] &amp;gt;= CurrentReportDate )&lt;BR /&gt;VAR FilteredTable =&lt;BR /&gt;FILTER (&lt;BR /&gt;TableOnAndAfter,&lt;BR /&gt;VAR TableOnAndBefore =&lt;BR /&gt;FILTER (&lt;BR /&gt;TableOnAndAfter,&lt;BR /&gt;'Table'[Report Date] &amp;lt;= EARLIER ( 'Table'[Report Date] )&lt;BR /&gt;)&lt;BR /&gt;VAR DaysDiff =&lt;BR /&gt;INT ( 'Table'[Report Date] - CurrentReportDate ) + 1&lt;BR /&gt;RETURN&lt;BR /&gt;COUNTROWS ( TableOnAndBefore ) = DaysDiff&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;MAXX ( FilteredTable, 'Table'[Report Date] )&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 14:01:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278160#M121693</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-06-11T14:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278174#M121694</link>
      <description>&lt;P&gt;Depending on how large your dataset is, this could be a viable solution (create 2 columns + 1 measure).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is New Run of Dates =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// flags row as true when there's a run of new dates associated with it
VAR _currDt = 'Table'[Dates]
VAR _prevDate = MAXX( FILTER( 'Table', 'Table'[Dates] &amp;lt; _currDt ) , 'Table'[Dates])
VAR _logical = NOT _currDt = _prevDate + 1
RETURN _logical&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group ID =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;// assigns an ID (1 , 2, .. X ) for each new group of consecutive dates
var _currDt = 'Table'[Dates]
var _iteratorTbl = FILTER( 'Table', 'Table'[Dates] &amp;lt;= _currDt )
var _uniqueDates = SUMMARIZE( _iteratorTbl, 'Table'[Dates], 'Table'[is New Run of Dates] )
RETURN 
SUMX(
    _uniqueDates,
    IF( [is New Run of Dates], 1) 
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the Group ID in place, you are able to identify groups of dates, and compute the max within the group...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Max of Run Group =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var _groups = VALUES( 'Table'[Group ID] )
var _tbl =
CALCULATETABLE(
    VALUES( 'Table'[Dates] )
    , ALL()
    , 'Table'[Group ID] in _groups
)
return 
MAXX( _tbl, 'Table'[Dates] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Comments on the solution here:&lt;BR /&gt;- I'm not keen on adding calculated columns to large models so while this is functional I'd give consideration to how large your table is here. The low cardinality on the T/F column, and the fact that the ID column is a Int type it should be of minimal impact to most models&lt;BR /&gt;- Setting the group ID in the table greatly improves the calculation performance of the resultant measure, better to have your groups identified row-by-row before computing the MAX of the date&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 14:31:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278174#M121694</guid>
      <dc:creator>Matt_Hecht</dc:creator>
      <dc:date>2023-06-11T14:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278709#M121717</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="573889" data-lia-user-login="Gayathri1992" class="lia-mention lia-mention-user"&gt;Gayathri1992&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I just tested it and seems to be working just fine. Of course the performance would be challenging. That you need to test with your full data.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Max Date = 
VAR CurrentReportDate = 'Table'[Reported Date]
VAR CurrentIDTable =
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Unique ID] ) )
VAR TableOnAndAfter =
    FILTER ( CurrentIDTable, 'Table'[Reported Date] &amp;gt;= CurrentReportDate )
VAR FilteredTable =
    FILTER (
        TableOnAndAfter,
        VAR TableOnAndBefore =
            FILTER (
                TableOnAndAfter,
                'Table'[Reported Date] &amp;lt;= EARLIER ( 'Table'[Reported Date] )
            )
        VAR DaysDiff =
            INT ( 'Table'[Reported Date] - CurrentReportDate ) + 1
        RETURN
            COUNTROWS ( TableOnAndBefore ) = DaysDiff
    )
RETURN
    MAXX ( FilteredTable, 'Table'[Reported Date] )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 12 Jun 2023 05:21:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278709#M121717</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-06-12T05:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278895#M121731</link>
      <description>&lt;P&gt;Hi Tamerj,&lt;/P&gt;&lt;P&gt;This is working for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; and thank you for so much for the quick solution. However just another question on the same, how can we exclude weekends in between if there are weekends i dont want to consider those as gaps.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 07:08:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278895#M121731</guid>
      <dc:creator>Gayathri1992</dc:creator>
      <dc:date>2023-06-12T07:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278998#M121739</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="573889" data-lia-user-login="Gayathri1992" class="lia-mention lia-mention-user"&gt;Gayathri1992&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Yes, sure&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;Max Date = 
VAR CurrentReportDate = 'Table'[Reported Date]
VAR CurrentIDTable =
    CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Unique ID] ) )
VAR TableOnAndAfter =
    FILTER ( CurrentIDTable, 'Table'[Reported Date] &amp;gt;= CurrentReportDate )
VAR FilteredTable =
    FILTER (
        TableOnAndAfter,
        VAR TableOnAndBefore =
            FILTER (
                TableOnAndAfter,
                'Table'[Reported Date] &amp;lt;= EARLIER ( 'Table'[Reported Date] )
            )
        VAR DaysDiff =
            COUNTROWS ( 
                FILTER ( 
                    CALENDAR ( CurrentReportDate, 'Table'[Reported Date] ),
                    NOT ( WEEKDAY ( [Date], 2 ) IN { 6, 7 } )
                )
            )
        RETURN
            COUNTROWS ( TableOnAndBefore ) = COALESCE ( DaysDiff, 1 )
    )
RETURN
    MAXX ( FilteredTable, 'Table'[Reported Date] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 07:51:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3278998#M121739</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-06-12T07:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Wanted to know the maximum date from list of dates if there is gap based on Unique ID</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3279253#M121760</link>
      <description>&lt;P&gt;Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; you are awesome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is working for me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 10:34:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Wanted-to-know-the-maximum-date-from-list-of-dates-if-there-is/m-p/3279253#M121760</guid>
      <dc:creator>Gayathri1992</dc:creator>
      <dc:date>2023-06-12T10:34:07Z</dc:date>
    </item>
  </channel>
</rss>

