<?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 Calculate difference between two rows with dependencies in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2472057#M67344</link>
    <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope someone can help me with the following:&lt;/P&gt;&lt;P&gt;I want to calculate the difference between two rows - but I want to do this only for rows where some Column-values are the same.&lt;/P&gt;&lt;P&gt;(btw: I already checked out the other posts about this topic: I saw the idea with the two indexes (one from 0, the other from1) and the usage of the EARLIER function - but I cannot apply this to my case - but maybe someone has an idea how to merge it all together &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with the following columns: eomployee number, date, start, end.&lt;/P&gt;&lt;P&gt;The table contains the working start and end time stamp of each employ on each day. The columns for start and end are formatted as datatype 'time' (short-time).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the duration of the breaks - for each employee on each day separately for each break.&lt;/P&gt;&lt;P&gt;That means, I need to substract the end time of the row above from the start time of the next line.&lt;/P&gt;&lt;P&gt;In the example for employee number 44, on 01.01.2022 we would have:&lt;/P&gt;&lt;P&gt;break 1: 14 min. (10:45 - 10:31)&lt;/P&gt;&lt;P&gt;break 2: 40 min. (13:10 - 12:30)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new column that will contain this break durations, but it should recognize when there is a new day and also when there is a new employee - that means it will leave some cells empty when calculating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I am struggling with this condition 'only for same day and only for same employee'&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;&lt;P&gt;Do I have to do the way with two indexes and a merge and calculate it within a new column and compare both, the date and the employee values to prevent calculating breaks between days ... or is there a better way with DAX?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone has a nicer way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Regards Vanessa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2022 16:24:26 GMT</pubDate>
    <dc:creator>backflash</dc:creator>
    <dc:date>2022-04-22T16:24:26Z</dc:date>
    <item>
      <title>Calculate difference between two rows with dependencies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2472057#M67344</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hope someone can help me with the following:&lt;/P&gt;&lt;P&gt;I want to calculate the difference between two rows - but I want to do this only for rows where some Column-values are the same.&lt;/P&gt;&lt;P&gt;(btw: I already checked out the other posts about this topic: I saw the idea with the two indexes (one from 0, the other from1) and the usage of the EARLIER function - but I cannot apply this to my case - but maybe someone has an idea how to merge it all together &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with the following columns: eomployee number, date, start, end.&lt;/P&gt;&lt;P&gt;The table contains the working start and end time stamp of each employ on each day. The columns for start and end are formatted as datatype 'time' (short-time).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the duration of the breaks - for each employee on each day separately for each break.&lt;/P&gt;&lt;P&gt;That means, I need to substract the end time of the row above from the start time of the next line.&lt;/P&gt;&lt;P&gt;In the example for employee number 44, on 01.01.2022 we would have:&lt;/P&gt;&lt;P&gt;break 1: 14 min. (10:45 - 10:31)&lt;/P&gt;&lt;P&gt;break 2: 40 min. (13:10 - 12:30)&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new column that will contain this break durations, but it should recognize when there is a new day and also when there is a new employee - that means it will leave some cells empty when calculating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I am struggling with this condition 'only for same day and only for same employee'&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;&lt;P&gt;Do I have to do the way with two indexes and a merge and calculate it within a new column and compare both, the date and the employee values to prevent calculating breaks between days ... or is there a better way with DAX?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope someone has a nicer way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;Regards Vanessa&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2022 16:24:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2472057#M67344</guid>
      <dc:creator>backflash</dc:creator>
      <dc:date>2022-04-22T16:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between two rows with dependencies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2472082#M67351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="348184" data-lia-user-login="backflash" class="lia-mention lia-mention-user"&gt;backflash&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you create a calculated column&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Break Time =
VAR CurrentStart = Table[Start]
VAR CurrentEnd = Table[End]
VAR PreviousEnd =
    MAXX (
        FILTER (
            CALCULATETABLE (
                Table,
                ALLEXCEPT ( Table, Table[Emplyee Number], Table[Date] )
            ),
            Table[End] &amp;lt; CurrentEnd
        ),
        Table[End]
    )
RETURN
    CurrentStart - PreviousEnd&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Apr 2022 16:39:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2472082#M67351</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-22T16:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between two rows with dependencies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474088#M67492</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks a lot - your code for the calculated column is working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I now have a break time on each new day (from 0:00 to start time)&amp;nbsp; - do you have an idea how I could have the cells of the break time empty, when there is a new day?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 07:18:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474088#M67492</guid>
      <dc:creator>backflash</dc:creator>
      <dc:date>2022-04-25T07:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between two rows with dependencies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474170#M67496</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="348184" data-lia-user-login="backflash" class="lia-mention lia-mention-user"&gt;backflash&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Break Time =
VAR CurrentStart = Table[Start]
VAR CurrentEnd = Table[End]
VAR PreviousEnd =
    MAXX (
        FILTER (
            CALCULATETABLE (
                Table,
                ALLEXCEPT ( Table, Table[Emplyee Number], Table[Date] )
            ),
            Table[End] &amp;lt; CurrentEnd
        ),
        Table[End]
    )
RETURN
    IF ( 
        NOT ISBLANK ( PreviousEnd ),
        CurrentStart - PreviousEnd
    )&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Apr 2022 07:45:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474170#M67496</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-04-25T07:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between two rows with dependencies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474236#M67503</link>
      <description>&lt;P&gt;Many thanks &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt; perfect!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 08:07:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-difference-between-two-rows-with-dependencies/m-p/2474236#M67503</guid>
      <dc:creator>backflash</dc:creator>
      <dc:date>2022-04-25T08:07:42Z</dc:date>
    </item>
  </channel>
</rss>

