<?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 with Conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953810#M10825</link>
    <description>&lt;P&gt;Well, you have two problems here. First, you need to flag the correct 500 rows to do your calculation on. Second, you need to do your calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first part is something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IsFirst500After200 = 
    VAR __Table500 = FILTER(ALL('Table'),[Response code] = 500 &amp;amp;&amp;amp; 'Table'[Index]&amp;lt;EARLIER('Table'[Index]))
    VAR __Table200 = FILTER(ALL('Table'),[Response code] = 200 &amp;amp;&amp;amp; 'Table'[Index]&amp;lt;EARLIER('Table'[Index]))
    VAR __Max500 = MAXX(__Table500,[Index])
    VAR __Max200 = MAXX(__Table200,[Index])    
    VAR __Flag = 
        SWITCH(TRUE(),
            [Response code] = 200,FALSE(),
            __Max500 &amp;gt; __Max200,FALSE(),
            __Max500 &amp;lt; 'Table'[Index] &amp;amp;&amp;amp; ISBLANK(__Max200),FALSE(),
            TRUE()
        )
RETURN
    __Flag&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Duration = 
    IF(
        [IsFirst500After200],
        VAR __Next200 = MINX(FILTER(ALL('Table'),'Table'[Index] &amp;gt; EARLIER('Table'[Index]) &amp;amp;&amp;amp; 'Table'[Response code] = 200),[Event time])
        RETURN DATEDIFF([Event time],__Next200,SECOND),
        BLANK()
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This second part is the identical technique used in MTBF.&amp;nbsp;&lt;A href="http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.&amp;nbsp;" target="_blank"&gt;http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached the PBIX file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 29 Feb 2020 16:26:53 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2020-02-29T16:26:53Z</dc:date>
    <item>
      <title>DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951788#M10711</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;Can someone help me out with the datediff measure with Conditions&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I need to calculate the datediff based on Response code i.e the first occurrence of 500 and the next occurrence of 200, that means the Time diff between Index ‘0’ row and index ‘4’ row (2/22/2020 17:23 - 2/22/2020 17:12 = 11 min)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Event time&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Response code&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Request Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Index&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020 17:12&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020 17:13&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020 17:14&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020 17:15&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020 17:23&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 22:16:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951788#M10711</guid>
      <dc:creator>usomaraju</dc:creator>
      <dc:date>2020-02-27T22:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951893#M10714</link>
      <description>&lt;P&gt;Hello!!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = DATEDIFF(CALCULATE(MAX(Hoja1[Event time]);Hoja1[Response code] =200 );CALCULATE(MIN(Hoja1[Event time]);Hoja1[Response code] = 500);MINUTE)&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps!!&lt;/P&gt;&lt;P&gt;Regards!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 01:26:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951893#M10714</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-28T01:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951979#M10720</link>
      <description>&lt;P&gt;Well, this seems like an issue that would involve EARLIER.&amp;nbsp;Please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, if you want the difference in days, you can always just subtract the dates and multiply by 1.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 02:56:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/951979#M10720</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-02-28T02:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953074#M10793</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Query that you given did not work,it gives the null values.&lt;/P&gt;&lt;P&gt;here i'm posting my complete table, can you please help on this.&lt;/P&gt;&lt;P&gt;We are trying to calculate time difference between&lt;FONT color="#ff0000"&gt; &lt;STRONG&gt;(first occurance of 500 - first occurance of 200)&lt;/STRONG&gt;&lt;/FONT&gt; and continue the same for the next occurance of 500 and 200.&lt;/P&gt;&lt;P&gt;example:event time of index '0' - event time of index '4'&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;event time of index '8' - event time of index '9'&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and so forth.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 15:29:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953074#M10793</guid>
      <dc:creator>usomaraju</dc:creator>
      <dc:date>2020-02-28T15:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953612#M10810</link>
      <description>&lt;P&gt;Can you share plz your dataset? No as image.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 29 Feb 2020 00:46:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953612#M10810</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-29T00:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953810#M10825</link>
      <description>&lt;P&gt;Well, you have two problems here. First, you need to flag the correct 500 rows to do your calculation on. Second, you need to do your calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first part is something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IsFirst500After200 = 
    VAR __Table500 = FILTER(ALL('Table'),[Response code] = 500 &amp;amp;&amp;amp; 'Table'[Index]&amp;lt;EARLIER('Table'[Index]))
    VAR __Table200 = FILTER(ALL('Table'),[Response code] = 200 &amp;amp;&amp;amp; 'Table'[Index]&amp;lt;EARLIER('Table'[Index]))
    VAR __Max500 = MAXX(__Table500,[Index])
    VAR __Max200 = MAXX(__Table200,[Index])    
    VAR __Flag = 
        SWITCH(TRUE(),
            [Response code] = 200,FALSE(),
            __Max500 &amp;gt; __Max200,FALSE(),
            __Max500 &amp;lt; 'Table'[Index] &amp;amp;&amp;amp; ISBLANK(__Max200),FALSE(),
            TRUE()
        )
RETURN
    __Flag&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second part:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Duration = 
    IF(
        [IsFirst500After200],
        VAR __Next200 = MINX(FILTER(ALL('Table'),'Table'[Index] &amp;gt; EARLIER('Table'[Index]) &amp;amp;&amp;amp; 'Table'[Response code] = 200),[Event time])
        RETURN DATEDIFF([Event time],__Next200,SECOND),
        BLANK()
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This second part is the identical technique used in MTBF.&amp;nbsp;&lt;A href="http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.&amp;nbsp;" target="_blank"&gt;http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached the PBIX file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Feb 2020 16:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/953810#M10825</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-02-29T16:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: DateDiff with Conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/955476#M10930</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the data not in the form of image&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Event time&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Response code&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Request Name&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Index&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:12:19 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:13:19 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:14:20 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:15:46 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:23:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:24:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:25:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 17:26:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 18.30:15 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 18:33:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 18:43:15 PM&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 18:44:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/22/2020&amp;nbsp; 18:45:15 PM&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;POST Write/CaseSavedEvent&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 02 Mar 2020 15:42:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DateDiff-with-Conditions/m-p/955476#M10930</guid>
      <dc:creator>usomaraju</dc:creator>
      <dc:date>2020-03-02T15:42:07Z</dc:date>
    </item>
  </channel>
</rss>

