<?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 detecting overlapping activities (all occurences) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/838769#M6301</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I would like to use a DAX formula that can detect a time overlap for the same person, being in two places at once (all occurrences).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Moreover, I would also like the formula to detect any overlapping period when the time period crosses over into the following day (row 7, attached screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) Finally, is it possible to have a formula that can work through a data set which has not been sorted in chronological order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date	Person	Start_Time	End_Time	Period Overlap
10-Sep-19	A	06:00:00	18:00:00	yes
10-Sep-19	A	12:00:00	00:00:00	yes
10-Sep-19	B	00:00:00	12:00:00	no
10-Sep-19	B	12:00:00	18:00:00	no
10-Sep-19	B	18:00:00	12:00:00	yes
11-Sep-19	A	00:00:00	12:00:00	no
11-Sep-19	A	12:00:00	00:00:00	yes
11-Sep-19	A	18:00:00	00:00:00	yes
11-Sep-19	B	00:00:00	06:00:00	yes
11-Sep-19	B	12:00:00	00:00:00	no&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="data" href="https://leicestercitycouncil-my.sharepoint.com/:x:/g/personal/massimo_gioia_leicester_gov_uk/Ee5U7F2NKsFDhUQJ86_02YoBN_wYUCZam81AbkDnrUy_ww?e=7Vvgkq" target="_self"&gt;file&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Nov 2019 09:05:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-11-11T09:05:49Z</dc:date>
    <item>
      <title>detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/838769#M6301</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I would like to use a DAX formula that can detect a time overlap for the same person, being in two places at once (all occurrences).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Moreover, I would also like the formula to detect any overlapping period when the time period crosses over into the following day (row 7, attached screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) Finally, is it possible to have a formula that can work through a data set which has not been sorted in chronological order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Date	Person	Start_Time	End_Time	Period Overlap
10-Sep-19	A	06:00:00	18:00:00	yes
10-Sep-19	A	12:00:00	00:00:00	yes
10-Sep-19	B	00:00:00	12:00:00	no
10-Sep-19	B	12:00:00	18:00:00	no
10-Sep-19	B	18:00:00	12:00:00	yes
11-Sep-19	A	00:00:00	12:00:00	no
11-Sep-19	A	12:00:00	00:00:00	yes
11-Sep-19	A	18:00:00	00:00:00	yes
11-Sep-19	B	00:00:00	06:00:00	yes
11-Sep-19	B	12:00:00	00:00:00	no&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="data" href="https://leicestercitycouncil-my.sharepoint.com/:x:/g/personal/massimo_gioia_leicester_gov_uk/Ee5U7F2NKsFDhUQJ86_02YoBN_wYUCZam81AbkDnrUy_ww?e=7Vvgkq" target="_self"&gt;file&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 09:05:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/838769#M6301</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-11T09:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/847847#M6595</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would first define the start / end date in this format dd-mm-yy hh:mm:ss with 2 calculated columns :&amp;nbsp;&lt;/P&gt;&lt;P&gt;For end date, I would check if end time is &amp;lt; or &amp;gt; start time to deduce if it is next day or not :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Start_date_full = 'Table'[Date]+'Table'[Start_Time]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;End_Date_full = If('Table'[End_Time]&amp;gt;='Table'[Start_Time];'Table'[Date]+'Table'[End_Time];'Table'[Date]+1+'Table'[End_Time])&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Then I would reuse these 2 calculated column to deduce overlap yes or no:&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Question 1 Period Overlap = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR _Person = 'Table'[Person] &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR _start = 'Table'[Start_date_full] &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR _end = 'Table'[End_Date_full]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR _condition_start_before= CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person &amp;amp;&amp;amp; _start &amp;lt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _end &amp;gt; 'Table'[Start_date_full])) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR _condition_start_between = CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person &amp;amp;&amp;amp; _start &amp;gt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _start &amp;lt; 'Table'[End_Date_full])) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If(_condition_start_between + _condition_start_before = 0;"no";"yes")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;for you 2nd question, same, I would reuse the 2 first calculated columns&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Question 2 overlapping period day = IF(DATEDIFF('Table'[Start_date_full];'Table'[End_Date_full];day)=1;"yes";"no")&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Question 3: yes the 2 calculated columns work fine with &lt;SPAN&gt;data set which has not been sorted in chronological order&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Let me know if that helps.&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Nov 2019 22:10:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/847847#M6595</guid>
      <dc:creator>M_L</dc:creator>
      <dc:date>2019-11-15T22:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/848951#M6623</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dear L_M

Thank you very much for your reply.

Your solution is perfect for what I was trying to do. 

Unfortunately, I forgot to consider in my sample the scenario where the overlapping calls start at the same time.

I have updated the sample data and the Gantt chart introducing one more occurrence that contemplates this other scenario (row 5).

I have tried to add a third conditions, _condition_start_same_time, but I can’t manage to make it work.

Could you please help me with this as well?

Best regard,
masG.

Date	Person	Start_Time	End_Time	Period Overlap
10-Sep-19	A	06:00:00	18:00:00	yes
10-Sep-19	A	12:00:00	00:00:00	yes
10-Sep-19	B	00:00:00	12:00:00	no
10-Sep-19	B	12:00:00	18:00:00	yes
10-Sep-19	B	12:00:00	18:00:00	yes
10-Sep-19	B	18:00:00	12:00:00	yes
11-Sep-19	A	00:00:00	12:00:00	no
11-Sep-19	A	12:00:00	00:00:00	yes
11-Sep-19	A	18:00:00	00:00:00	yes
11-Sep-19	B	00:00:00	06:00:00	yes
11-Sep-19	B	12:00:00	00:00:00	no&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:49:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/848951#M6623</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-18T12:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/848956#M6624</link>
      <description>&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 12:53:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/848956#M6624</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-18T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/849423#M6640</link>
      <description>&lt;P&gt;The 3rd condition "__condition_start_equal" could be added like below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please indicate if this is this fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Question 1 Period Overlap = 
VAR _Person = 'Table'[Person] 
VAR _start = 'Table'[Start_date_full] 
VAR _end = 'Table'[End_Date_full]
VAR _condition_start_before= CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person &amp;amp;&amp;amp; _start &amp;lt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _end &amp;gt;'Table'[Start_date_full])) 
VAR _condition_start_between = CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person &amp;amp;&amp;amp; _start &amp;gt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _start &amp;lt; 'Table'[End_Date_full])) 
VAR _condition_start_equal = CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person &amp;amp;&amp;amp; _start = 'Table'[Start_date_full] )) 
VAR __results = If(_condition_start_between + _condition_start_before + _condition_start_equal &amp;lt;= 1 ;"no";"yes")
RETURN 
__results&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this one is shorter :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Question 1 Period Overlap short = 
VAR _Person = 'Table'[Person] 
VAR _start = 'Table'[Start_date_full] 
VAR _end = 'Table'[End_Date_full]

VAR _condition_overlap = CALCULATE(COUNT('Table'[Person]);FILTER('Table';'Table'[Person]=_Person 
&amp;amp;&amp;amp; ((_start &amp;lt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _end &amp;gt;'Table'[Start_date_full]) 
|| _start = 'Table'[Start_date_full] 
|| (_start &amp;gt; 'Table'[Start_date_full] &amp;amp;&amp;amp; _start &amp;lt; 'Table'[End_Date_full]))))

RETURN If(_condition_overlap &amp;lt;= 1 ;"no";"yes")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 21:34:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/849423#M6640</guid>
      <dc:creator>M_L</dc:creator>
      <dc:date>2019-11-18T21:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/850258#M6666</link>
      <description>&lt;LI-CODE lang="markup"&gt;Dear &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="186518" data-lia-user-login="M_L" class="lia-mention lia-mention-user"&gt;M_L&lt;/a&gt;,

Your DAX statement is now perfect for my purposes.

Thank you so much for your help,
@masG&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:14:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/850258#M6666</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-11-19T12:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: detecting overlapping activities (all occurences)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/4115925#M163390</link>
      <description>&lt;P&gt;Hi, this DAX looks pretty good but by trying to using it, the issue is that it compare with the first row with itself. I tried to add to the filter to exclude the same row that it's trying to compare but after saving it keeps showing "working on it" to the infinity&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 14:40:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/detecting-overlapping-activities-all-occurences/m-p/4115925#M163390</guid>
      <dc:creator>alessiobayware</dc:creator>
      <dc:date>2024-08-23T14:40:35Z</dc:date>
    </item>
  </channel>
</rss>

