<?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: SOLVED.DAX Measure previous 3 months average in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495278#M28827</link>
    <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , try like the given example. Prefer a date table &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-12,MONTH)) ,&lt;BR /&gt;CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH), not(isblank((Sales[Sales]))))) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dividing by no of months. Also using a column from the fact table to make sure it does not count month from date table without data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;radacad&lt;/A&gt; &lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;sqlbi&lt;/A&gt; &lt;A href="https://www.youtube.com/playlist?list=PLPaNVDMhUXGYLz-w8ERQOo3KYARs7GgG-" target="_blank"&gt;My Video Series&lt;/A&gt; Appreciate your Kudos. &lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2020 03:33:01 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2020-11-16T03:33:01Z</dc:date>
    <item>
      <title>SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495230#M28826</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having an issue on my DAX measure code that getting the average of previous 3 months. presently i'm getting incorrect result in my Visualization. The Correct values For April, the avg value of (Jan-Mar) should be 84.14%, May, the avg value (Feb-Apr) should be 85.45%.&amp;nbsp; for Nov, the avg value&amp;nbsp; of (Aug-Oct) is 84.99%. I'm using a Date Table. May I Know what is the problem with my DAX Code? Is there any other approach to get the average 3 mos.? any help is very much appreciated. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DAX Code:&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;AvgPrv3Months =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var avprev3mos = if(ISBLANK([FG %]),BLANK(),IF(COUNTROWS(DATESBETWEEN(DateTable[Date],EDATE(MIN(DateTable[Date]),-3),MIN(DateTable[Date])-1))&amp;gt;61,CALCULATE(AVERAGEX(values(DateTable[Date]),[FG %]),DATESBETWEEN(DateTable[Date],EDATE(MIN(DateTable[Date]),-3),MIN(DateTable[Date])-1)),BLANK()))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return avprev3mos&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Incorrect Value:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Nov 2020 09:37:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495230#M28826</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-16T09:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495278#M28827</link>
      <description>&lt;P&gt;Anonymous&lt;/LI-USER&gt; , try like the given example. Prefer a date table &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rolling 3 = divide( CALCULATE(sum(Sales[Sales]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date]),-12,MONTH)) ,&lt;BR /&gt;CALCULATE(distinctCOUNT('Date'[Month Year]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH), not(isblank((Sales[Sales]))))) &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dividing by no of months. Also using a column from the fact table to make sure it does not count month from date table without data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :&lt;A href="https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions" target="_blank"&gt;radacad&lt;/A&gt; &lt;A href="https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/" target="_blank"&gt;sqlbi&lt;/A&gt; &lt;A href="https://www.youtube.com/playlist?list=PLPaNVDMhUXGYLz-w8ERQOo3KYARs7GgG-" target="_blank"&gt;My Video Series&lt;/A&gt; Appreciate your Kudos. &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 03:33:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495278#M28827</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-16T03:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495362#M28828</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;, the FG% is&amp;nbsp; a measure.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 04:44:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495362#M28828</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-16T04:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495414#M28829</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , Try like &lt;/P&gt;
&lt;P&gt;AvgPrv3Months =&lt;BR /&gt;divide( CALCULATE([FG %],DATESINPERIOD('DateTable'[Date ],MAX('DateTable'[Date]),-12,MONTH)) ,&lt;BR /&gt;CALCULATE(distinctCOUNT('DateTable'[Month Year]),DATESINPERIOD('DateTable'[Date],MAX('DateTable'[Date]),-12,MONTH), not(isblank([FG %]))))&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 05:45:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495414#M28829</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-16T05:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495448#M28830</link>
      <description>&lt;P&gt;I tried this code and its working. the problem is the current month was included plus the previous 2 month.&amp;nbsp; How can i exclude the current month and extend the calculation to previous 3 month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Average of previous 3 months = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AVERAGEX ( VALUES ( DateTable[MonthYear] ), [FG %] ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATESINPERIOD ( DateTable[Date], MAX ( DateTable[Date] ), -3, MONTH )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;img /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Nov 2020 06:02:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495448#M28830</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-16T06:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495521#M28831</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , Try like this example&lt;/P&gt;
&lt;P&gt;Rolling 3 till last month = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(dateadd(Sales[Sales Date],-1,month)),-3,MONTH))&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 06:39:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495521#M28831</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-16T06:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495972#M28835</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;Thank you very much. I modified the code and its alerady working.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;AVERAGEX ( VALUES ( DateTable[MonthYear] ), [FG %] ),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;DATESINPERIOD ( DateTable[Date], ENDOFMONTH(DATEADD(DateTable[Date],-1, MONTH )), -3,MONTH))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Nov 2020 09:36:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1495972#M28835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-16T09:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1496282#M28846</link>
      <description>&lt;LI-CODE lang="csharp"&gt;[3M Avg] =
// __monthCount tells you how many months
// you want to use to get the average;
// you can change it to any number you want;
// to get a 6M average you just change to 6
var __monthCount = 3
var __anchorDate = MAX( DateTable[Date] )
var __periodToAvgOver =
    DATESINPERIOD(
        DateTable[Date],
        EOMONTH( __anchorDate, -1 ),
        (-1) * __monthCount,
        MONTH
    )
var __canCalculate =
    // check if there are enough months
    // to go back; works only if DateTable
    // is marked as a Date table in the model
    CALCULATE(
        DISTINCTCOUNT( DateTable[MonthYear] ) = __monthCount,
        __periodToAvgOver
    )
var __output = 
    if( __canCalculate,
        CALCULATE(
            AVERAGEX(
                VALUES( DateTable[MonthYear] ),
                [FG %]
            ),
            __periodToAvgOver
        )
    )
return
    __output&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Nov 2020 11:42:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1496282#M28846</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-16T11:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1496404#M28850</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt; , Can you accept the appropriate solution?&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 12:48:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1496404#M28850</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-11-16T12:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: SOLVED.DAX Measure previous 3 months average</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1506105#M29202</link>
      <description>&lt;P&gt;&amp;nbsp;Thank you for the reply. May i know if this will work with filter?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 02:15:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/SOLVED-DAX-Measure-previous-3-months-average/m-p/1506105#M29202</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-20T02:15:00Z</dc:date>
    </item>
  </channel>
</rss>

