<?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: How to group several  shifts with StartDTM and EndDTM in sevral rows up as one duty in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3194861#M115965</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="442752" data-lia-user-login="Daweiwang" class="lia-mention lia-mention-user"&gt;Daweiwang&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Pleas refer to my pbix file to see if it helps you.&lt;/P&gt;
&lt;P&gt;Create another table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table 2 = GENERATESERIES(MIN('Table'[STARTDTE]),MAX('Table'[ENDDTM]),TIME(0,30,0))&lt;/LI-CODE&gt;
&lt;P&gt;Then create 2 columns.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Category = 
var _a = MAXX(FILTER('Table',[Index]=EARLIER('Table'[Index])-1),[ENDDTM])
var _b = DATEDIFF(_a,[STARTDTE],MINUTE)
var _c = IF(_b&amp;lt;=30,1,0)
return COUNTROWS(FILTER('Table',[Index]&amp;lt;=EARLIER('Table'[Index])&amp;amp;&amp;amp;DATEDIFF(MAXX(FILTER('Table',[Index]=EARLIER('Table'[Index])-1),[ENDDTM]),[STARTDTE],MINUTE)&amp;gt;=30))+1&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Column = 
var _start = MINX(FILTER('Table',[Category]=EARLIER('Table'[Category])),[STARTDTE])
var _end = MAXX(FILTER('Table',[Category]=EARLIER('Table'[Category])),[ENDDTM])
var _timetable = GENERATESERIES(_start,_end,TIME(0,15,0))
var _Flag = ADDCOLUMNS(_timetable,"Flag",IF(TIME(23,30,00)&amp;lt;=TIME(HOUR([Value]),MINUTE([Value]),SECOND([Value]))||TIME(HOUR([Value]),MINUTE([Value]),SECOND([Value]))&amp;lt;=TIME(05,00,00),1,0))
return IF(SUMX(_Flag,[Flag])&amp;gt;0,"night duty")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;BR /&gt;Community Support Team _ Rongtie&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 02:59:26 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-04-20T02:59:26Z</dc:date>
    <item>
      <title>How to group several  shifts with StartDTM and EndDTM in sevral rows up as one duty</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3190483#M115703</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck by this issue for days.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My purpose is to idendty the shifts as one duty because it's one duty to a human, but I can't do it in DAX or M query in the back end.&amp;nbsp; I need to identify them as one duty first and then identify night duties out of these group-up duties, whih any duty falls upon the time period 11:30pm to 5:00am next day would be a night duty.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the shift gap between each other is less than 30 minutes, these shifts are considered as part of the duty.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I do it please? Thank you in advance.&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, 17 Apr 2023 05:26:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3190483#M115703</guid>
      <dc:creator>Daweiwang</dc:creator>
      <dc:date>2023-04-17T05:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to group several  shifts with StartDTM and EndDTM in sevral rows up as one duty</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3194861#M115965</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="442752" data-lia-user-login="Daweiwang" class="lia-mention lia-mention-user"&gt;Daweiwang&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Pleas refer to my pbix file to see if it helps you.&lt;/P&gt;
&lt;P&gt;Create another table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table 2 = GENERATESERIES(MIN('Table'[STARTDTE]),MAX('Table'[ENDDTM]),TIME(0,30,0))&lt;/LI-CODE&gt;
&lt;P&gt;Then create 2 columns.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Category = 
var _a = MAXX(FILTER('Table',[Index]=EARLIER('Table'[Index])-1),[ENDDTM])
var _b = DATEDIFF(_a,[STARTDTE],MINUTE)
var _c = IF(_b&amp;lt;=30,1,0)
return COUNTROWS(FILTER('Table',[Index]&amp;lt;=EARLIER('Table'[Index])&amp;amp;&amp;amp;DATEDIFF(MAXX(FILTER('Table',[Index]=EARLIER('Table'[Index])-1),[ENDDTM]),[STARTDTE],MINUTE)&amp;gt;=30))+1&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Column = 
var _start = MINX(FILTER('Table',[Category]=EARLIER('Table'[Category])),[STARTDTE])
var _end = MAXX(FILTER('Table',[Category]=EARLIER('Table'[Category])),[ENDDTM])
var _timetable = GENERATESERIES(_start,_end,TIME(0,15,0))
var _Flag = ADDCOLUMNS(_timetable,"Flag",IF(TIME(23,30,00)&amp;lt;=TIME(HOUR([Value]),MINUTE([Value]),SECOND([Value]))||TIME(HOUR([Value]),MINUTE([Value]),SECOND([Value]))&amp;lt;=TIME(05,00,00),1,0))
return IF(SUMX(_Flag,[Flag])&amp;gt;0,"night duty")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank" rel="noopener"&gt;How to Get Your Question Answered Quickly&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;BR /&gt;Community Support Team _ Rongtie&lt;/P&gt;
&lt;P&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 02:59:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3194861#M115965</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-04-20T02:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to group several  shifts with StartDTM and EndDTM in sevral rows up as one duty</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3199319#M116231</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello Rongtie,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for your help, I tried your code but Power BI is like "Working on it" and it didn't stop unitl I force stop it. Maybe something is wrong with it, which kept the code looping. I am not sure about it.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 04:54:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-group-several-shifts-with-StartDTM-and-EndDTM-in-sevral/m-p/3199319#M116231</guid>
      <dc:creator>Daweiwang</dc:creator>
      <dc:date>2023-04-21T04:54:17Z</dc:date>
    </item>
  </channel>
</rss>

