<?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: Finding the difference between the time from first and last occurrence in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503475#M69271</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Thank you! unfortunately, your suggestion didn't work for me. It freezes powerbi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what I did. Any suggestions? Additionally, my time needs to stay in unix.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Column =&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var _current = Data[unix time]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var _previous = MAXX(FILTER(Data,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Data[sensor]=EARLIER(Data[sensor]) &amp;amp;&amp;amp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Data[unix time]&amp;gt;EARLIER(Data[unix time]) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;),Data[unix time])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;return&amp;nbsp;&lt;/P&gt;&lt;P&gt;_current - _previous )&lt;/P&gt;</description>
    <pubDate>Tue, 10 May 2022 04:59:17 GMT</pubDate>
    <dc:creator>xsaldana</dc:creator>
    <dc:date>2022-05-10T04:59:17Z</dc:date>
    <item>
      <title>Finding the difference between the time from first and last occurrence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503232#M69251</link>
      <description>&lt;P&gt;Hello! I am trying to find the difference in unixtime from when a sensor was first registered to when it was registered again. I color coated the chart to empashize the sensor type. The "Time since last reading" column is the one that I am attempting to create and the one to the right of it has the equations. I am having issue because the pH sensor has 3 readings at different depths, but I only take the difference when the three readings appear again. Opposingly, I only recieve one readign for the ambient temp, water temp, and oxygen level. Any suggestions?&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 00:14:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503232#M69251</guid>
      <dc:creator>xsaldana</dc:creator>
      <dc:date>2022-05-10T00:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the difference between the time from first and last occurrence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503244#M69252</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="376027" data-lia-user-login="xsaldana" class="lia-mention lia-mention-user"&gt;xsaldana&lt;/a&gt;&amp;nbsp;Seems like you want something like MTBF:&amp;nbsp;See my article on Mean Time Between Failure (MTBF) which uses EARLIER: &lt;A href="http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586" target="_blank"&gt;http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586&lt;/A&gt;.&lt;BR /&gt;The basic pattern is:&lt;BR /&gt;Column =&amp;nbsp;&lt;BR /&gt;&amp;nbsp; VAR __Current = [Value]&lt;BR /&gt;&amp;nbsp; VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] &amp;lt; EARLIER('Table'[Date])),[Date])&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])&lt;BR /&gt;RETURN&lt;BR /&gt;&amp;nbsp; __Current - __Previous&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, this might be handy:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Quick-Measures-Gallery/Unix2UTC-and-UTC2Unix/m-p/620012#M292" target="_blank"&gt;Unix2UTC and UTC2Unix - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 00:31:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503244#M69252</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-05-10T00:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the difference between the time from first and last occurrence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503475#M69271</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;Thank you! unfortunately, your suggestion didn't work for me. It freezes powerbi.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what I did. Any suggestions? Additionally, my time needs to stay in unix.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Column =&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var _current = Data[unix time]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var _previous = MAXX(FILTER(Data,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Data[sensor]=EARLIER(Data[sensor]) &amp;amp;&amp;amp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Data[unix time]&amp;gt;EARLIER(Data[unix time]) &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;),Data[unix time])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;return&amp;nbsp;&lt;/P&gt;&lt;P&gt;_current - _previous )&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 04:59:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2503475#M69271</guid>
      <dc:creator>xsaldana</dc:creator>
      <dc:date>2022-05-10T04:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the difference between the time from first and last occurrence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2504587#M69312</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="376027" data-lia-user-login="xsaldana" class="lia-mention lia-mention-user"&gt;xsaldana&lt;/a&gt;&amp;nbsp;Seems like your &amp;gt; sign should be a &amp;lt; sign. And, you could use your Index potentially instead of unix time value for finding previous. Also, not sure about that last ). How many rows are there? Also, you *might* get better performance from this variation:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
var _sensor = Data[sensor]
var _current = Data[unix time]
var _previous = MAXX(FILTER(Data,
                       Data[sensor] = _sensor &amp;amp;&amp;amp;
                       Data[unix time] &amp;lt; _current
               ),Data[unix time])
return 
_current - _previous&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 10:56:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2504587#M69312</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2022-05-10T10:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the difference between the time from first and last occurrence</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2509430#M69565</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="376027" data-lia-user-login="xsaldana" class="lia-mention lia-mention-user"&gt;xsaldana&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try the following formula:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column = 
VAR _current = Data[unix time]
VAR _previous =
    MAXX (
        FILTER (
            Data,
            Data[sensor] = EARLIER ( Data[sensor] )
                &amp;amp;&amp;amp; Data[Depth (m)] = EARLIER ( Data[Depth (m)] )
                &amp;amp;&amp;amp; Data[unix time] &amp;lt; EARLIER ( Data[unix time] )
        ),
        Data[unix time]
    )
RETURN
    IF ( ISBLANK ( _previous ), BLANK (), _current - _previous )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.&lt;BR /&gt;Best Regards,&lt;BR /&gt;Winniz&lt;BR /&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, 12 May 2022 05:58:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Finding-the-difference-between-the-time-from-first-and-last/m-p/2509430#M69565</guid>
      <dc:creator>v-kkf-msft</dc:creator>
      <dc:date>2022-05-12T05:58:38Z</dc:date>
    </item>
  </channel>
</rss>

