<?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 Last and average between dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3085513#M107816</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to replicate the following table in Power BI but am struggling with writing the DAX for calculating some of the columns.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I cannot seem to get the last formal inspection date or the two last columns to work as when I change the format to latest date for the last inspection date column it says all of the last inspection dates for all projects were 31/12/2029.&lt;/P&gt;&lt;P&gt;Here is what it currently looks like, with the 'Last Formal Inspection Date' currently showing all inspection dates.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have the following attempted DAX with the variable names for getting the days between inspections to try and get the last two average columns from the original Excel screenshot:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AvgDaysBetweenFormalInspections = 
VAR CurrentProject = ALL(Project[ProjectName])
VAR CurrentDate = ALL('Date of Inspection'[date])
VAR LastInspection = 
    CALCULATE(
        MAX('Date of Inspection'[date]),
        FILTER(
            ALL(Project),
            Project[ProjectName] = CurrentProject &amp;amp;&amp;amp;
            ALL('Date of Inspection'[date]) &amp;lt; CurrentDate
        )
    )
RETURN IF (LastInspection = BLANK(), BLANK(), CurrentDate - LastInspection)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This currently doesn't work as it says 'a table of multiple values was supplied where a single value was expected'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this is because I am live connected or that it is because I am using 'ALL', but if anyone can assist me on any of the 3 columns it would be hugely appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2023 17:48:10 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-02-17T17:48:10Z</dc:date>
    <item>
      <title>Last and average between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3085513#M107816</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to replicate the following table in Power BI but am struggling with writing the DAX for calculating some of the columns.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I cannot seem to get the last formal inspection date or the two last columns to work as when I change the format to latest date for the last inspection date column it says all of the last inspection dates for all projects were 31/12/2029.&lt;/P&gt;&lt;P&gt;Here is what it currently looks like, with the 'Last Formal Inspection Date' currently showing all inspection dates.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have the following attempted DAX with the variable names for getting the days between inspections to try and get the last two average columns from the original Excel screenshot:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;AvgDaysBetweenFormalInspections = 
VAR CurrentProject = ALL(Project[ProjectName])
VAR CurrentDate = ALL('Date of Inspection'[date])
VAR LastInspection = 
    CALCULATE(
        MAX('Date of Inspection'[date]),
        FILTER(
            ALL(Project),
            Project[ProjectName] = CurrentProject &amp;amp;&amp;amp;
            ALL('Date of Inspection'[date]) &amp;lt; CurrentDate
        )
    )
RETURN IF (LastInspection = BLANK(), BLANK(), CurrentDate - LastInspection)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This currently doesn't work as it says 'a table of multiple values was supplied where a single value was expected'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this is because I am live connected or that it is because I am using 'ALL', but if anyone can assist me on any of the 3 columns it would be hugely appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 17:48:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3085513#M107816</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-17T17:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Last and average between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3085963#M107873</link>
      <description>&lt;P&gt;hi Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try like:&lt;/P&gt;&lt;DIV&gt;AvgDaysBetweenFormalInspections =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;VAR CurrentProject =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MAX(Project[ProjectName])&lt;/DIV&gt;&lt;DIV&gt;VAR CurrentDate =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MAX('Date of Inspection'[date])&lt;/DIV&gt;&lt;DIV&gt;VAR LastInspection =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; CALCULATE(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MAX('Date of Inspection'[date]),&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FILTER(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ALL(Project),&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Project[ProjectName] = CurrentProject &amp;amp;&amp;amp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Date of Inspection'[date]&amp;lt; CurrentDate&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; )&lt;/DIV&gt;&lt;DIV&gt;RETURN&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;IF(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LastInspection = BLANK(),&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BLANK(),&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CurrentDate - LastInspection&lt;/DIV&gt;&lt;DIV&gt;)&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Feb 2023 06:32:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3085963#M107873</guid>
      <dc:creator>FreemanZ</dc:creator>
      <dc:date>2023-02-18T06:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: Last and average between dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3087491#M108002</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately it didn't work, it is now returning all rows as 30/12/1899.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 09:02:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Last-and-average-between-dates/m-p/3087491#M108002</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-02-20T09:02:48Z</dc:date>
    </item>
  </channel>
</rss>

