<?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 duration from fixed date/time in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970655#M99249</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a column with fixed time which begins from 2000-01-01 00:00:00&lt;/P&gt;&lt;P&gt;If we find 2000-01-02 03:10:10 in that column it means 27h, 10 min, 10 sec in duration. How can I calculate and get it as result?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a great day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Dec 2022 11:41:58 GMT</pubDate>
    <dc:creator>Kratchie</dc:creator>
    <dc:date>2022-12-15T11:41:58Z</dc:date>
    <item>
      <title>Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970655#M99249</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a column with fixed time which begins from 2000-01-01 00:00:00&lt;/P&gt;&lt;P&gt;If we find 2000-01-02 03:10:10 in that column it means 27h, 10 min, 10 sec in duration. How can I calculate and get it as result?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a great day&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 11:41:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970655#M99249</guid>
      <dc:creator>Kratchie</dc:creator>
      <dc:date>2022-12-15T11:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970675#M99251</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Measure = &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_mindate&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (2)'&lt;/SPAN&gt;&lt;SPAN&gt;[Column1]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (2)'&lt;/SPAN&gt;&lt;SPAN&gt;[Column1]&lt;/SPAN&gt;&lt;SPAN&gt;)) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_h&lt;/SPAN&gt;&lt;SPAN&gt; = &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;_mindate&lt;/SPAN&gt;&lt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t;&lt;SPAN&gt;_m&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;"m "&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;_s&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&lt;/SPAN&gt;&lt;SPAN&gt;"s"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;end result:&lt;BR /&gt;&lt;img /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;My LinkedIn: &lt;A href="https://www.linkedin.com/in/n%C3%A4ttiahov-00001/" target="_blank"&gt;https://www.linkedin.com/in/n%C3%A4ttiahov-00001/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Dec 2022 11:53:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970675#M99251</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2022-12-15T11:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970740#M99256</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395279" data-lia-user-login="Kratchie" class="lia-mention lia-mention-user"&gt;Kratchie&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try to create a column with this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Column = &lt;/SPAN&gt;&lt;SPAN&gt;FORMAT&lt;/SPAN&gt;&lt;SPAN&gt;([Duration]-&lt;/SPAN&gt;&lt;SPAN&gt;DATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;2000&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;"HH:MM:SS"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;i tried and it worked like this:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 15 Dec 2022 12:24:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970740#M99256</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-12-15T12:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970871#M99270</link>
      <description>&lt;P&gt;I assume you are later going to aggregate your durations in a measure, so please see this article for a good way to handle durations as decimals (in days) so you can easily do math and use them in visuals, but then display them as hh:mm, etc. when needed.&lt;/P&gt;&lt;P&gt;&lt;A href="https://hoosierbi.com/2021/10/16/calculate-and-format-durations-in-dax/" target="_blank"&gt;Calculate and Format Durations in DAX – Hoosier BI&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 13:26:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970871#M99270</guid>
      <dc:creator>ppm1</dc:creator>
      <dc:date>2022-12-15T13:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970971#M99284</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343431" data-lia-user-login="ValtteriN" class="lia-mention lia-mention-user"&gt;ValtteriN&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I created a new visual table and added only DURATION column with your script it worked like a charm. BUT when i'm adding more columns it stopped to work by any reason. Seems that only timestamps with seconds still works partly (only hours + seconds), but when it's whole hour. It doesnt work?!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 15:18:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970971#M99284</guid>
      <dc:creator>Kratchie</dc:creator>
      <dc:date>2022-12-15T15:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970976#M99285</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your script works perfectly with hours only. When it's more than 24 hours like 1 day + 6 hour it only shows 6:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 15:18:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2970976#M99285</guid>
      <dc:creator>Kratchie</dc:creator>
      <dc:date>2022-12-15T15:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2971146#M99301</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="443516" data-lia-user-login="ppm1" class="lia-mention lia-mention-user"&gt;ppm1&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This I have done before without any problem when it's two columns with both start/end date+time (split it into 4 columns (start&amp;amp;date, end&amp;amp;date, start&amp;amp;time, end&amp;amp;time) but now I need to get duration from fixed timestamps as I wrote above which isnt that easy. I have googled for different solutions but couldn't find any.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 15:19:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2971146#M99301</guid>
      <dc:creator>Kratchie</dc:creator>
      <dc:date>2022-12-15T15:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2971930#M99377</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395279" data-lia-user-login="Kratchie" class="lia-mention lia-mention-user"&gt;Kratchie&lt;/a&gt;&amp;nbsp; hmm,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;That seems quite weird. The first things that come to my mind are te following: &lt;BR /&gt;&lt;BR /&gt;1. Are there some other dimension information or slicers affecting the visual?&amp;nbsp;&lt;BR /&gt;2. Is the data format similar in both your example and the data in question&lt;BR /&gt;&lt;BR /&gt;When I tried to re-create this the formula worked well even with whole hours and dates across different months:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 22:27:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2971930#M99377</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2022-12-15T22:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2972247#M99393</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395279" data-lia-user-login="Kratchie" class="lia-mention lia-mention-user"&gt;Kratchie&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;not sure about your ultimate goal, try this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Column = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;_d&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;TRUNC&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;[Duration]&lt;/SPAN&gt;&lt;SPAN&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;DATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&g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IV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Dec 2022 02:36:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2972247#M99393</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2022-12-16T02:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate duration from fixed date/time</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2976169#M99651</link>
      <description>&lt;P&gt;This is perfect thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="460868" data-lia-user-login="FreemanZ" class="lia-mention lia-mention-user"&gt;FreemanZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 09:08:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-duration-from-fixed-date-time/m-p/2976169#M99651</guid>
      <dc:creator>Kratchie</dc:creator>
      <dc:date>2022-12-19T09:08:30Z</dc:date>
    </item>
  </channel>
</rss>

