<?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: Average Days Between Dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088541#M108094</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&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;</description>
    <pubDate>Mon, 20 Feb 2023 17:27:54 GMT</pubDate>
    <dc:creator>Greg_Deckler</dc:creator>
    <dc:date>2023-02-20T17:27:54Z</dc:date>
    <item>
      <title>Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088536#M108093</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to get the average days between inspection dates. Below is a breakdown of current dates by project (with blue and green dots being 2 different projects).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Below is my attempted DAX for getting the days between inspections, with an average calculation for averages later on:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DaysBetweenInspectionsALL = 
VAR CurrentProject = SELECTEDVALUE(Project[ProjectName])
VAR CurrentDate = SELECTEDVALUE('Date of Inspection'[date])
VAR LastInspectionDate = 
    CALCULATE(
    MAX('Date'[Date]),
    FILTER(
        ALL(Project),
        Project[ProjectName] = CurrentProject &amp;amp;&amp;amp;
        SELECTEDVALUE('Date of Inspection'[date]) &amp;lt; CurrentDate))
RETURN 
IF(LastInspectionDate = BLANK(), BLANK(), CurrentDate - LastInspectionDate)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this has returned all row values as '27/12/1774', even with whole number formatting. I belive this might be from using an incorrect field in the LastInspectionDate variable. Any help would be appreciated, thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 17:24:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088536#M108093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-20T17:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088541#M108094</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt;&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;</description>
      <pubDate>Mon, 20 Feb 2023 17:27:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088541#M108094</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2023-02-20T17:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088676#M108098</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a quick fix could be&lt;/P&gt;
&lt;P&gt;DaysBetweenInspectionsALL =&lt;BR /&gt;VAR CurrentProject =&lt;BR /&gt;SELECTEDVALUE ( Project[ProjectName] )&lt;BR /&gt;VAR CurrentDate =&lt;BR /&gt;SELECTEDVALUE ( 'Date of Inspection'[date] )&lt;BR /&gt;VAR LastInspectionDate =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;MAX ( 'Date'[Date] ),&lt;BR /&gt;FILTER (&lt;BR /&gt;ALL ( Project ),&lt;BR /&gt;Project[ProjectName] = CurrentProject&lt;BR /&gt;&amp;amp;&amp;amp; CALCULATE ( SELECTEDVALUE ( 'Date of Inspection'[date] ) ) &amp;lt; CurrentDate&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF ( LastInspectionDate = BLANK (), BLANK (), CurrentDate - LastInspectionDate )&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 19:00:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3088676#M108098</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-20T19:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093076#M108420</link>
      <description>&lt;P&gt;Hi &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;,&lt;/P&gt;&lt;P&gt;I tried writing the DAX for this but the EARLIER function wasn't letting me use any fields or functions - could you help with writing out the DAX for my case? The below is my attempt:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AverageDaysBetweenInspectionsALL = 
VAR _Current = CALCULATE(MAX('Date of Inspection'[date]))
VAR _PreviousDate = MAXX(FILTER('Date of Inspection', 'Date of Inspection'[date] &amp;lt; EARLIER('Date of Inspection'[date])), 'Date'[Date])
VAR _Previous = MAXX(FILTER('Date of Inspection', 'Date of Inspection'[date]=_PreviousDate), CALCULATE(MAX('Date of Inspection'[date])))
RETURN
  _Current - _Previous&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:55:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093076#M108420</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-22T14:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093085#M108421</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is still returning all rows as&amp;nbsp;&lt;SPAN&gt;'27/12/1774' unfortunately!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:21:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093085#M108421</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-22T14:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Average Days Between Dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093104#M108422</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please share a sampler pbix file to work with.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 14:25:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Average-Days-Between-Dates/m-p/3093104#M108422</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-02-22T14:25:08Z</dc:date>
    </item>
  </channel>
</rss>

