<?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: DAX Rolling 3 months by periods that are not the exact month dates in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2842761#M90851</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;thanks for this!! very nice solution! you helped me with part of my headaches in the last days.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Oct 2022 14:18:44 GMT</pubDate>
    <dc:creator>adelinadamian</dc:creator>
    <dc:date>2022-10-14T14:18:44Z</dc:date>
    <item>
      <title>DAX Rolling 3 months by periods that are not the exact month dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2614943#M75942</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a fact table and a date dimension joined by a date&lt;/P&gt;&lt;P&gt;The dim_date table is like the one below, the Period column divides the dates and isn't by exact months. Example the Period&lt;BR /&gt;2021_04 Starts on 05/04/2021 and finishes on 02/05/2021 and it is April&lt;BR /&gt;2021_05 Starts on 02/05/2021 and finishes on 30/05/2021 and it is May&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I want a rolling 3 Months DAX Measure by Period&lt;BR /&gt;I created a column Financial Date with the last day of the month so for the period&lt;BR /&gt;2021_04 I have 30/04/2021 from 05/04/2021 until 02/05/2021&lt;BR /&gt;2021_05 I have 31/05/2021 from 03/05/2021 until 30/05/2021&lt;/P&gt;&lt;P&gt;I already did some DAX but because I used the Period to filter everything went ok the problem is to roll the 3 months to calculate the average I am thinking to do it by Financial Date with DATESINPERIOD&lt;/P&gt;&lt;P&gt;I started with&lt;BR /&gt;VAR Lastselecteddate = MAX(Dim_Date[FinancialDATE])&lt;BR /&gt;&lt;BR /&gt;VAR Result =&lt;BR /&gt;AVERAGEX(&lt;BR /&gt;VALUES(Dim_Date[Financial Year Month]), Dim_Date[Amount ]&lt;BR /&gt;)&lt;BR /&gt;Return&lt;BR /&gt;COUNTROWS(DATESINPERIOD(Dim_Date[Date],Lastselecteddate,-3,MONTH))&lt;/P&gt;&lt;P&gt;What I want is the next rolling 3 months average by period&lt;BR /&gt;2021_04&lt;BR /&gt;2021_05&lt;BR /&gt;2021_06&lt;BR /&gt;and so on but because I defined this period with Financial Date one period is one "fake" month&lt;/P&gt;&lt;P&gt;Do you have some clues on how can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 21:40:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2614943#M75942</guid>
      <dc:creator>ofeliajesus</dc:creator>
      <dc:date>2022-07-01T21:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Rolling 3 months by periods that are not the exact month dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2615127#M75955</link>
      <description>&lt;P&gt;Just number the months from 1 to whatever their number (each month in each year must be considered different, no two will have the same number, of course), consecutively, and use this very number to calculate the average. That's the easiest way. If the max month number in the current context is, say, 20, then it'll be easy to refer to months like 18, 19, 20, to calculate the 3-month lagging average. If you want another average, just manipulate the current month number as explained above.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Jul 2022 08:14:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2615127#M75955</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-02T08:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Rolling 3 months by periods that are not the exact month dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2619518#M76244</link>
      <description>&lt;P&gt;Can you give me some clue about the DAX formula I need to manipulate with the measure below ... On top of it, I need to apply the&lt;BR /&gt;rolling 3 periods starting in 2021_04&lt;BR /&gt;The Output will be&lt;BR /&gt;2021_06 - 2021_04 + 2021_05 + 2021_06 = (17+15+9)/3&lt;BR /&gt;2021_07 - 2021_05 + 2021_06 + 2021_07 = (15+9+16)/3&lt;BR /&gt;and so on&lt;/P&gt;&lt;P&gt;Quotes per Period =&lt;BR /&gt;VAR tblNumOfWeeksInPeriod=&lt;BR /&gt;SUMMARIZE(&lt;BR /&gt;Dim_Date&lt;BR /&gt;,Dim_Date[Period]&lt;BR /&gt;,Dim_Date[# of Weeks]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;VAR SuMOfWeeksInPeriod = SUMX(tblNumOfWeeksInPeriod,Dim_Date[# of Weeks])&lt;/P&gt;&lt;P&gt;Var quotesperweek =&lt;BR /&gt;MROUND(&lt;BR /&gt;DIVIDE(&lt;BR /&gt;'Table Measures'[Total Region]&lt;BR /&gt;,SuMOfWeeksInPeriod&lt;BR /&gt;)&lt;BR /&gt;,1&lt;BR /&gt;)&lt;BR /&gt;Return&lt;BR /&gt;quotesperweek&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 10:11:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2619518#M76244</guid>
      <dc:creator>ofeliajesus</dc:creator>
      <dc:date>2022-07-05T10:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Rolling 3 months by periods that are not the exact month dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2620488#M76292</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// Say you want to calculate a 3-period rolling avg
// of a measure. Name the measure [M]. The periods
// must have consecutive numbers in the calendar,
// so that we can move through them using simple
// arithmetic. Let the sequence of periods start at 1
// and increment by 1. Let the field be named
// PeriodSeqno.

[M 3-Period Rolling Avg] =
// Set the number of periods to calculate
// the average over.
var PeriodCount = 3
// First, get the last visible period.
var LastPeriodSeqno = MAX( Dim_Date[PeriodSeqno] )
// Then, get the periods over which to calc.
var PeriodsToAverageOver =
    CALCULATETABLE(
        DISTINCT( Dim_Date[PeriodSeqno] ),
        // Here's the place where you use the fact that
        // all the periods are consecutively numbered.
        // In fact, the counting does not have to start
        // at 1 but it has to increment by 1.
        Dim_Date[PeriodSeqno] &amp;lt;= LastPeriodSeqno,
        Dim_Date[PeriodSeqno] &amp;gt; LastPeriodSeqno - PeriodCount,
        REMOVEFILTERS( Dim_Date )
    )
// We need to make sure that there are indeed
// PeriodCount periods in the set. Otherwise,
// the average will not be correct. This could happen
// if we were too close to the beginning of the calendar.
var ShouldCalculate =
    COUNTROWS( PeriodsToAverageOver ) = PeriodCount
var Result =
    if( ShouldCalculate,
        CALCULATE(
            AVERAGEX(
                PeriodsToAverageOver,
                [M]
            ),
            REMOVEFILTERS( Dim_Date )
        )
    )
return
    Result&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 05 Jul 2022 16:45:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2620488#M76292</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-07-05T16:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Rolling 3 months by periods that are not the exact month dates</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2842761#M90851</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;thanks for this!! very nice solution! you helped me with part of my headaches in the last days.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 14:18:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Rolling-3-months-by-periods-that-are-not-the-exact-month/m-p/2842761#M90851</guid>
      <dc:creator>adelinadamian</dc:creator>
      <dc:date>2022-10-14T14:18:44Z</dc:date>
    </item>
  </channel>
</rss>

