<?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: Is there a way to count the amount of date overlaps? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/945012#M10245</link>
    <description>&lt;P&gt;Please try to use this. This time it should work.&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;
&lt;LI-CODE lang="markup"&gt;# Overlaps = 
var __oneClientVisible = hasonevalue(Data[EHRClientFK])
var __result = if(__oneClientVisible,
	
    // Bear in mind that if a value is
    // of type boolean then you have
    // to convert it into a number for
    // SUMX to work. To convert it it's
    // OK to multiply it by 1 or add 0 to it.
	var __data = Data
	return
	SUMX(
		__data,
		var __a = Data[AdmDate]
		var __b = Data[DischDate]
		return 0 +
        (
            SUMX(
                __data,
                var __x = Data[AdmDate]
                var __y = Data[DischDate]
                var __maxOfMins =
                    max(__a, __x)
                var __minOfMaxes =
                    min(__b, __y)
                return
                    // Need to decide if &amp;lt; or &amp;lt;=.
                    // If it's possible to have
                    // intervals where both ends
                    // are the same, then you
                    // have to use &amp;lt;=.
                    1 * (__maxOfMins &amp;lt; __minOfMaxes)
            ) &amp;gt; 1
        )
    ) + 0
)
return
	__result&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, 24 Feb 2020 14:44:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-24T14:44:31Z</dc:date>
    <item>
      <title>Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/942291#M10070</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following Table:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Where DischDate = '2020-02-20' means no discharge date; just to replace NULL value&lt;/P&gt;&lt;P&gt;Is there way in DAX Power BI - to calculate the amount of Overlapping dates for each Client (EHRClientFK), as per following&lt;/P&gt;&lt;P&gt;"Overlap" schema:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;According to the schema only EHRClientFK values dates = 2,3,4,5 should be counted&lt;/P&gt;&lt;P&gt;Values 8,9,10 have are only single; values 6,7 have no Ovrelaps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, my goal is to have something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EHRClientFK &amp;nbsp; # of Overlapping Dates&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for any suggestions!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 08:11:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/942291#M10070</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2020-02-21T08:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/942600#M10078</link>
      <description>&lt;P&gt;To see the number of overlaps per row in Table you could use a measure like this:&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;# of Overlapping Dates 1 =
SUMX (
    'Table';
    COUNTROWS (
        FILTER (
            ALL ( 'Table' );
            [EHRClientFK] = EARLIER ( [EHRClientFK] )
                &amp;amp;&amp;amp; 'Table'[AdmDate] &amp;lt;= EARLIER ( 'Table'[DischDate] )
                &amp;amp;&amp;amp; 'Table'[DischDate] &amp;gt;= EARLIER ( 'Table'[AdmDate] )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with this is that every single row will count itself as overlapping. So, we need to add a check for that. If there is some kind of unique column in the table, use that one. I assume there are no duplicates and add the check like this:&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;# of Overlapping Dates 2 =
SUMX (
    'Table';
    COUNTROWS (
        FILTER (
            ALL ( 'Table' );
            [EHRClientFK] = EARLIER ( [EHRClientFK] )
                &amp;amp;&amp;amp; 'Table'[AdmDate] &amp;lt;= EARLIER ( 'Table'[DischDate] )
                &amp;amp;&amp;amp; 'Table'[DischDate] &amp;gt;= EARLIER ( 'Table'[AdmDate] )
                &amp;amp;&amp;amp; NOT (
                    'Table'[DischDate] = EARLIER ( 'Table'[DischDate] )
                        &amp;amp;&amp;amp; 'Table'[AdmDate] = EARLIER ( 'Table'[AdmDate] )
                )
        )
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will work if you show all columns of the table. For example both rows with EHRClientFK=2 will show 2. But if we remove the dates those two rows will sum up to 4. not what we wanted. This can be solved by grouping on EHRClientFK and the number of overlaps and then sum:&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;# of Overlapping Dates 3 =
VAR NewTable =
    ADDCOLUMNS (
        'Table';
        "Overlapping"; COUNTROWS (
            FILTER (
                ALL ( 'Table' );
                [EHRClientFK] = EARLIER ( [EHRClientFK] )
                    &amp;amp;&amp;amp; 'Table'[AdmDate] &amp;lt;= EARLIER ( 'Table'[DischDate] )
                    &amp;amp;&amp;amp; 'Table'[DischDate] &amp;gt;= EARLIER ( 'Table'[AdmDate] )
                    &amp;amp;&amp;amp; NOT (
                        'Table'[DischDate] = EARLIER ( 'Table'[DischDate] )
                            &amp;amp;&amp;amp; 'Table'[AdmDate] = EARLIER ( 'Table'[AdmDate] )
                    )
            )
        )
    )
RETURN
    SUMX ( GROUPBY ( NewTable; [EHRClientFK]; [Overlapping] ); [Overlapping] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This got a little bit complicated for a simple task. Could probably be made easier in some way... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2020 11:15:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/942600#M10078</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-21T11:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943859#M10169</link>
      <description>OK. It looks like the condition for overlapping periods is max(min(P1), min(P2)) &amp;lt; min(max(P1), max(P2)), where min([a,b])=a and max([a,b]) = b. Question: Is it true that the maximum number of overlaps for a client is 2? Please answer it and then I'll give you a simple measure.</description>
      <pubDate>Sat, 22 Feb 2020 14:39:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943859#M10169</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T14:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943864#M10170</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Assumption:
// for each EHRClientFK there are
// at most 2 records in the table
// 'Data' and AdmDate and DischDate
// can't be BLANK. Also,
// AdmDate &amp;lt;= DischDate.

[# Overlaps] :=
var __oneClientVisible = hasonevalue(Data[EHRClientFK])
var __result = if(__oneClientVisible,
	
	var __rowsVisible = countrows(Data)
	var __maxOfMins =
		max(Data[AdmDate])
	var __minOfMaxes =
		min(Data[DischDate])
	var __isOverlap =
		// you have to decide what kind of
		// overlap you want, that is whether
		// to use &amp;lt; or &amp;lt;=
		__maxofMins &amp;lt; __minOfMaxes
	return
		switch(__rowsVisible
			1, 1,
			2, 2 * __isOverlap,
			
			// This should not happen
			-1
		)
	
)
return
	__result&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;Please analyze the code and adjust according to your needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 15:08:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943864#M10170</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T15:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943865#M10171</link>
      <description>Anonymous&lt;/LI-USER&gt;, please stop using EARLIER. This is a feature of the language that is deprecated and hard to understand. Instead, please use variables. Thanks.</description>
      <pubDate>Sat, 22 Feb 2020 15:02:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943865#M10171</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T15:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943956#M10182</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;Yes, variables are probably better. I wrote a lot of DAX in the early days of Power Pivot and back then EARLIER was the only option. But I can't find any information that it has been deprecated. dax.guide has labeled it "Not recommended", but nothing is mentioned in the official Microsoft docs as far as I can see: &lt;A href="https://docs.microsoft.com/en-us/dax/earlier-function-dax" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/dax/earlier-function-dax&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 20:39:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943956#M10182</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T20:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943961#M10184</link>
      <description>I might have used a wrong word but the gist holds nevertheless. EARLIER is one of the worst functions in DAX (actually it's horrible) and since there are variables, there's no need to use it and confuse people anymore.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Sat, 22 Feb 2020 21:08:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943961#M10184</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-22T21:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943982#M10191</link>
      <description>&lt;P&gt;Answering your question - No, There could be more than 2 periods for one client.&lt;/P&gt;&lt;P&gt;As many periods as there are overlaps according to my schema...&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 23:35:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943982#M10191</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2020-02-22T23:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943983#M10192</link>
      <description>&lt;P&gt;Sorry, a bit confusing... I'll look carefully&lt;/P&gt;&lt;P&gt;But - what if there are more than 3 overlaps?&amp;nbsp;&lt;/P&gt;&lt;P&gt;There could be as many overlaps as possible ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EHRClientFK is a foreign key - contains the numbers of episodes (AdmDate &amp;lt;-&amp;gt; DischDate) for the Client...&lt;/P&gt;&lt;P&gt;It could be any numbers of episodes (AdmDate &amp;lt;-&amp;gt; DischDate variations)... &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 23:41:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/943983#M10192</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2020-02-22T23:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/944108#M10205</link>
      <description>Then you have to show us how you want to deal with some more complex situations. Just show what happens when there are 3 different periods in one selection EHRClientFK. Becasue then the periods can have many more different arrangements than the ones you showed for just 2 periods.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Sun, 23 Feb 2020 12:35:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/944108#M10205</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-23T12:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/944550#M10237</link>
      <description>&lt;P&gt;If there 3 or more different periods in one selection EHRClientFK - same goal - I want to only count the "Overlap" cases&lt;/P&gt;&lt;P&gt;Doesn't matter - how many periods in EHRClientFK - 3,4,5,6 or more - I want to only count those which are Overlaps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example -&lt;/P&gt;&lt;P&gt;EHRClientFK &amp;nbsp;&amp;nbsp; AdmDate &amp;nbsp; &amp;nbsp; &amp;nbsp; DischDate&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 12/16/2016 &amp;nbsp;&amp;nbsp; 1/26/2017&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/4/2017 &amp;nbsp;&amp;nbsp; 11/30/2017&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5/8/2018 &amp;nbsp; &amp;nbsp;&amp;nbsp; 7/4/2018&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 7/10/2018&amp;nbsp; 12/31/2050&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7/11/2018&amp;nbsp; 11/14/2018&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 8/9/2018 &amp;nbsp; 12/31/2050&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example case&amp;nbsp;&lt;SPAN&gt;5/8/2018&amp;nbsp; &amp;lt;-&amp;gt; &amp;nbsp; 7/4/2018 shouldn't be calculated because this one has no overlaps!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So here should be 5 overlapping dates for EHRClientFK&amp;nbsp; (out of 6 total)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope this makes more sense...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 05:31:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/944550#M10237</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2020-02-24T05:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/945012#M10245</link>
      <description>&lt;P&gt;Please try to use this. This time it should work.&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;
&lt;LI-CODE lang="markup"&gt;# Overlaps = 
var __oneClientVisible = hasonevalue(Data[EHRClientFK])
var __result = if(__oneClientVisible,
	
    // Bear in mind that if a value is
    // of type boolean then you have
    // to convert it into a number for
    // SUMX to work. To convert it it's
    // OK to multiply it by 1 or add 0 to it.
	var __data = Data
	return
	SUMX(
		__data,
		var __a = Data[AdmDate]
		var __b = Data[DischDate]
		return 0 +
        (
            SUMX(
                __data,
                var __x = Data[AdmDate]
                var __y = Data[DischDate]
                var __maxOfMins =
                    max(__a, __x)
                var __minOfMaxes =
                    min(__b, __y)
                return
                    // Need to decide if &amp;lt; or &amp;lt;=.
                    // If it's possible to have
                    // intervals where both ends
                    // are the same, then you
                    // have to use &amp;lt;=.
                    1 * (__maxOfMins &amp;lt; __minOfMaxes)
            ) &amp;gt; 1
        )
    ) + 0
)
return
	__result&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, 24 Feb 2020 14:44:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/945012#M10245</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-24T14:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/945053#M10251</link>
      <description>&lt;P&gt;The measure above should do the trick if AdmDate and DischDate can't be BLANK and AdmDate &amp;lt;= DischDate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, if you remove the condition on just one ClientFK visible... the measure will also make sense. It'll return the number of overlaps in the selection, whatever the selection is, not necessarily one client only.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 14:42:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/945053#M10251</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-24T14:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946513#M10384</link>
      <description>&lt;P&gt;Thank you, let me try over the next 2 days and I'll get back if it worked!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Btw, just to inform - this Episode table has no unique values&lt;/P&gt;&lt;P&gt;EHRClientFK is a foreign key, refered from the other table where it is a unique values of ClientID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will this still work?&lt;/P&gt;&lt;P&gt;(I'll try of course)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Feb 2020 06:35:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946513#M10384</guid>
      <dc:creator>Hell-1931</dc:creator>
      <dc:date>2020-02-25T06:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946720#M10392</link>
      <description>Well, whether it gives you what you're looking for or not depends on... what you're looking for. To know whether or not a measure does what you think it does you have to test it on all of your cases... There is no other way unless you can mathematically prove by deduction that it will do what you want it to. Right? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Tue, 25 Feb 2020 08:45:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946720#M10392</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-25T08:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946723#M10393</link>
      <description>By the way... If this is THE measure, please give Kudos (the button with the thumbs-up on it).&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Tue, 25 Feb 2020 08:46:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/946723#M10393</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-25T08:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to count the amount of date overlaps?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/1175551#M18252</link>
      <description>&lt;P&gt;Hello, is it possible to modify tgis measure, if i need a count of overlaping days?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 08:38:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Is-there-a-way-to-count-the-amount-of-date-overlaps/m-p/1175551#M18252</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-06-23T08:38:42Z</dc:date>
    </item>
  </channel>
</rss>

