<?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: DateDiff giving negative result when the next date-time is less than 24 hrs difference in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235888#M167551</link>
    <description>&lt;P&gt;Try something like this in the Return statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RETURN IF(
_WorkTimeElapsed &amp;lt; 0,
_WorkTimeElapsed + (24 * 60),
_WorkTimeElapsed 
)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 09 Oct 2024 23:35:20 GMT</pubDate>
    <dc:creator>SachinNandanwar</dc:creator>
    <dc:date>2024-10-09T23:35:20Z</dc:date>
    <item>
      <title>DateDiff giving negative result when the next date-time is less than 24 hrs difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235847#M167545</link>
      <description>&lt;P&gt;This is for a calculated column.&lt;/P&gt;&lt;P&gt;Whenever the [exit time] is the next day, but within 24 hours of [enter time], I get a negative result for minutes.&lt;/P&gt;&lt;P&gt;All other aspects, except this, are working fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Minutes =&lt;BR /&gt;VAR _NonWorkingDays =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNTROWS('Calendar'),&lt;BR /&gt;'Calendar'[Day Type] &amp;lt;&amp;gt; "Work Day"&lt;BR /&gt;)&lt;BR /&gt;VAR _WorkTimeElapsed =&lt;BR /&gt;DATEDIFF(AuditLog[Enter_Time],AuditLog[Exit_Time], MINUTE) - (_NonWorkingDays* 24 * 60)&lt;BR /&gt;RETURN&lt;BR /&gt;_WorkTimeElapsed&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 22:51:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235847#M167545</guid>
      <dc:creator>noannish</dc:creator>
      <dc:date>2024-10-09T22:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff giving negative result when the next date-time is less than 24 hrs difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235863#M167547</link>
      <description>&lt;P&gt;I think it is because your exit time is before enter time in the 24 hour period.&lt;BR /&gt;&lt;BR /&gt;Can you post some data ?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 23:04:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235863#M167547</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-10-09T23:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff giving negative result when the next date-time is less than 24 hrs difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235877#M167548</link>
      <description>&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Minutes&lt;/TD&gt;&lt;TD&gt;Enter_Time&lt;/TD&gt;&lt;TD&gt;Exit_Time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-32&lt;/TD&gt;&lt;TD&gt;2/19/2024 8:47:00 AM&lt;/TD&gt;&lt;TD&gt;2/20/2024 8:15:00 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-153&lt;/TD&gt;&lt;TD&gt;6/19/2024 11:32:00 AM&lt;/TD&gt;&lt;TD&gt;6/20/2024 8:59:00 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;-328&lt;/TD&gt;&lt;TD&gt;2/19/2024 2:18:00 PM&lt;/TD&gt;&lt;TD&gt;2/20/2024 8:50:00 AM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 09 Oct 2024 23:25:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235877#M167548</guid>
      <dc:creator>noannish</dc:creator>
      <dc:date>2024-10-09T23:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff giving negative result when the next date-time is less than 24 hrs difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235888#M167551</link>
      <description>&lt;P&gt;Try something like this in the Return statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RETURN IF(
_WorkTimeElapsed &amp;lt; 0,
_WorkTimeElapsed + (24 * 60),
_WorkTimeElapsed 
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Oct 2024 23:35:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4235888#M167551</guid>
      <dc:creator>SachinNandanwar</dc:creator>
      <dc:date>2024-10-09T23:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff giving negative result when the next date-time is less than 24 hrs difference</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4261978#M168921</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="180616" data-lia-user-login="noannish" class="lia-mention lia-mention-user"&gt;noannish&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your statement, I think your result is correct.&lt;/P&gt;
&lt;P&gt;Working backwards from the results you gave, I think&amp;nbsp;&lt;SPAN&gt;the&amp;nbsp;_NonWorkingDays = 1 and&amp;nbsp;&lt;SPAN&gt;(_NonWorkingDays* 24 * 60) in your code will return 1440.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Since I don't know exactly what your Calendar table looks like, if there is a issue with this part of the result, please check it.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Please make sure the datediff(minutes) between [Enter Time] and [Exit Time].&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;I think the datediff(minutes) in your sample are all less than 1440, so&amp;nbsp;datediff(minutes) - &lt;SPAN&gt;(_NonWorkingDays* 24 * 60)&amp;nbsp;&lt;SPAN&gt;will return&amp;nbsp;&lt;SPAN class=""&gt;negative result.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Rico Zhou&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 09:31:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-giving-negative-result-when-the-next-date-time-is-less/m-p/4261978#M168921</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-10-29T09:31:01Z</dc:date>
    </item>
  </channel>
</rss>

