<?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: Avg calculation filtered for existing data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371973#M126907</link>
    <description>&lt;P&gt;Try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales avg all dates =
VAR FirstSale =
    CALCULATE ( MIN ( 'Sales'[Date] ), REMOVEFILTERS ( 'Dates' ) )
VAR FirstVisibleDate =
    EOMONTH ( FirstSale, -1 ) + 1
VAR LastSale =
    CALCULATE ( MAX ( 'Sales'[Date] ), REMOVEFILTERS ( 'Dates' ) )
VAR LastVisibleDate =
    EOMONTH ( FirstSale, 0 )
VAR MinDate =
    MIN ( 'Dates'[Date] )
VAR MaxDate =
    MAX ( 'Dates'[Date] )
VAR Result =
    IF (
        MinDate &amp;gt;= FirstVisibleDate
            &amp;amp;&amp;amp; MaxDate &amp;lt;= LastVisibleDate,
        CALCULATE (
            AVERAGEX ( VALUES ( 'Dates'[Month &amp;amp; Year] ), [Sales] ),
            REMOVEFILTERS ( 'Dates' )
        )
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 09 Aug 2023 10:04:17 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2023-08-09T10:04:17Z</dc:date>
    <item>
      <title>Avg calculation filtered for existing data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371543#M126879</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I need to calculate the Average Sales only for the period that Sales data exist (red line).&lt;/P&gt;&lt;P&gt;The measure I created though expands to all dates in my Date table (blue line).&lt;/P&gt;&lt;P&gt;How can I fix that using DAX?&lt;/P&gt;&lt;P&gt;I tried DATESBETWEEN as shown, with no success.&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;</description>
      <pubDate>Wed, 09 Aug 2023 05:26:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371543#M126879</guid>
      <dc:creator>Thimios</dc:creator>
      <dc:date>2023-08-09T05:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Avg calculation filtered for existing data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371973#M126907</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales avg all dates =
VAR FirstSale =
    CALCULATE ( MIN ( 'Sales'[Date] ), REMOVEFILTERS ( 'Dates' ) )
VAR FirstVisibleDate =
    EOMONTH ( FirstSale, -1 ) + 1
VAR LastSale =
    CALCULATE ( MAX ( 'Sales'[Date] ), REMOVEFILTERS ( 'Dates' ) )
VAR LastVisibleDate =
    EOMONTH ( FirstSale, 0 )
VAR MinDate =
    MIN ( 'Dates'[Date] )
VAR MaxDate =
    MAX ( 'Dates'[Date] )
VAR Result =
    IF (
        MinDate &amp;gt;= FirstVisibleDate
            &amp;amp;&amp;amp; MaxDate &amp;lt;= LastVisibleDate,
        CALCULATE (
            AVERAGEX ( VALUES ( 'Dates'[Month &amp;amp; Year] ), [Sales] ),
            REMOVEFILTERS ( 'Dates' )
        )
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Aug 2023 10:04:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371973#M126907</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-08-09T10:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Avg calculation filtered for existing data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371989#M126910</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="240987" data-lia-user-login="johnt75" class="lia-mention lia-mention-user"&gt;johnt75&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Suggested measure works as far as calculation is concerned, but not as expected in visual.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 10:15:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3371989#M126910</guid>
      <dc:creator>Thimios</dc:creator>
      <dc:date>2023-08-09T10:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Avg calculation filtered for existing data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3372064#M126912</link>
      <description>&lt;P&gt;Use Performance Analyzer to copy the query for the visual into DAX Studio. You can then use the Define Measure feature in DAX Studio to change the measure to return each of the intermediate variables in turn, that should identify which variable is being calculated incorrectly.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 11:13:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Avg-calculation-filtered-for-existing-data/m-p/3372064#M126912</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2023-08-09T11:13:45Z</dc:date>
    </item>
  </channel>
</rss>

