<?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: Calculate the time difference in seconds from the current time to the previous time for the same ID. in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138177#M164382</link>
    <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2024 18:02:33 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-09-06T18:02:33Z</dc:date>
    <item>
      <title>Calculate the time difference in seconds from the current time to the previous time for the same ID.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138020#M164375</link>
      <description>&lt;P&gt;How can I create a measure that calculates the difference in seconds from the current Timestamp to the previous Timestamp of the same CallingSsi(ID)?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;BR /&gt;Exemple:&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;</description>
      <pubDate>Fri, 06 Sep 2024 16:07:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138020#M164375</guid>
      <dc:creator>Magliari</dc:creator>
      <dc:date>2024-09-06T16:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the time difference in seconds from the current time to the previous time for the same ID.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138177#M164382</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 18:02:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138177#M164382</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-09-06T18:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the time difference in seconds from the current time to the previous time for the same ID.</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138700#M164412</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="684947" data-lia-user-login="Magliari" class="lia-mention lia-mention-user"&gt;Magliari&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I hope I've understood your issue correctly. It appears that the first screenshot you provided contains duplicate rows, and since you wish to create a measure to display the time difference.; assuming your table has only two columns, I have devised this solution for you.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I appreciate your attempt to clarify the scenario with a smaller example in the second screenshot. However, the time difference you've calculated there is incorrect because you only considered the time, not the date.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would really appreciate it if you could take some time to carefully formulate your questions and provide appropriate, anonymized sample data and the expected results you need. Otherwise, we may have to make assumptions that might not be correct. Please adhere to the instructions provided by&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have created a DAX measure to calculate the time difference in seconds for "CallingSsi" from its last available point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Timestamp Difference (in Seconds) = 
VAR _filteredTbl =
    GROUPBY (
        FILTER (
            ALL ( TimestampTbl ),
            TimestampTbl[Timestamp] &amp;lt;= MIN ( TimestampTbl[Timestamp] )
                &amp;amp;&amp;amp; TimestampTbl[CallingSsi] = MIN ( TimestampTbl[CallingSsi] )
        ),
        TimestampTbl[Timestamp],
        TimestampTbl[CallingSsi]
    )
VAR _top2rowsTbl =
    SELECTCOLUMNS (
        TOPN ( 2, _filteredTbl, TimestampTbl[Timestamp], DESC ),
        "timestamp", TimestampTbl[Timestamp]
    )
VAR _currentTimestamp =
    TOPN ( 1, _top2rowsTbl, [timestamp], DESC )
VAR _previousTimestamp =
    TOPN ( 1, _top2rowsTbl, [timestamp], ASC )
RETURN
    DATEDIFF ( _previousTimestamp, _currentTimestamp, SECOND )&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Here is the screenshot of the solution:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I hope this will offer the solution you require. If you continue to encounter issues, please inform us and supply a relevant sample dataset along with the expected outcomes for us to fully comprehend the problem.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Udit&lt;BR /&gt;&lt;BR /&gt;If this post &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accepting it as the solution&lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;Appreciate your Kudo &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":rocket:"&gt;🚀&lt;/span&gt; Let's Connect: &lt;A href="https://www.linkedin.com/in/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkedIn&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://www.youtube.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;YouTube&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://medium.com/@quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;Medium&lt;/STRONG&gt;&lt;/A&gt; || &lt;A href="https://github.com/quantumudit/" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;GitHub&lt;/STRONG&gt;&lt;/A&gt;&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":sparkles:"&gt;✨&lt;/span&gt; Visit My Linktree: &lt;A href="https://linktr.ee/quantumudit" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;LinkTree&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Sep 2024 09:21:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-the-time-difference-in-seconds-from-the-current-time/m-p/4138700#M164412</guid>
      <dc:creator>quantumudit</dc:creator>
      <dc:date>2024-09-07T09:21:08Z</dc:date>
    </item>
  </channel>
</rss>

