Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Power BI filter limitng the data range

Hello,

 

I have encountered issues with including 3 months rolling average on power BI

 

for example, if the selected filter starts from January, it needs to show the 3months average rolling price of December, January and Feburary. However, since the filter starts from January, December data cannot be used to calculate the 3months rolling average... 

let's say if the average price of the december is 10000 and January 20000 and feburary 30000

then the 3month rolling average of January supposed to be 20000. but since the filter limits the starting data, it would show 25000 instead which is average of January and feburary.

 

Anyone knows how to solve this issue?

Thanks in advance

3 ACCEPTED SOLUTIONS
Sahir_Maharaj
Super User
Super User

Hello @Anonymous,

 

Can you please try this approach:

3MonthRollingAverage = 
VAR CurrentDate = MAX('DateTable'[Date])
RETURN
    CALCULATE(
        AVERAGE('YourTable'[Price]),
        DATESINPERIOD('DateTable'[Date], CurrentDate, -3, MONTH)
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

danextian
Super User
Super User

Hi @Anonymous 

You need to have a separate dates table that's been marked as a dates table. You can use DATESINPERIOD to get the total for the past x periods. 

3 Months Rolling Amount = 
CALCULATE (
    [Total Revenue],
    DATESINPERIOD ( Dates[Date], MAX ( Dates[Date] ), -3, MONTH )
)
3 Months Rolling Average = 
CALCULATE (
    AVERAGEX (
        ADDCOLUMNS (
            SUMMARIZE ( Dates, Dates[Month and Year] ),
            "@rev", [Total Revenue]
        ),
        [@rev]
    ),
    DATESINPERIOD ( Dates[Date], MAX ( Dates[Date] ), -3, MONTH )
)

danextian_0-1731540539562.png

danextian_1-1731540567096.png

 

Please see attached sample pbix for details.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Anonymous
Not applicable

Hi @Anonymous 

 

Thanks for the reply from Sahir_Maharaj and danextian , please allow me to provide another insight:

 

Galactichub , the following testing is for your reference:

 

Sample:

vxuxinyimsft_0-1731636083119.png

 

1. Create a calculated table as the slicer

Slicer = VALUES('Table'[Month])

 

2. Create a measure as follows

Measure = 
VAR _selected = SELECTEDVALUE('Slicer'[Month])
var _lastMonth = EOMONTH(_selected, -2) + 1
VAR _nextMonth = EOMONTH(_selected, 1)
VAR _average = AVERAGEX(FILTER('Table', [Month] >= _lastMonth && [Month] <= _nextMonth), [average])
RETURN
_average

 

Output:

vxuxinyimsft_1-1731636243922.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous 

 

Thanks for the reply from Sahir_Maharaj and danextian , please allow me to provide another insight:

 

Galactichub , the following testing is for your reference:

 

Sample:

vxuxinyimsft_0-1731636083119.png

 

1. Create a calculated table as the slicer

Slicer = VALUES('Table'[Month])

 

2. Create a measure as follows

Measure = 
VAR _selected = SELECTEDVALUE('Slicer'[Month])
var _lastMonth = EOMONTH(_selected, -2) + 1
VAR _nextMonth = EOMONTH(_selected, 1)
VAR _average = AVERAGEX(FILTER('Table', [Month] >= _lastMonth && [Month] <= _nextMonth), [average])
RETURN
_average

 

Output:

vxuxinyimsft_1-1731636243922.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

danextian
Super User
Super User

Hi @Anonymous 

You need to have a separate dates table that's been marked as a dates table. You can use DATESINPERIOD to get the total for the past x periods. 

3 Months Rolling Amount = 
CALCULATE (
    [Total Revenue],
    DATESINPERIOD ( Dates[Date], MAX ( Dates[Date] ), -3, MONTH )
)
3 Months Rolling Average = 
CALCULATE (
    AVERAGEX (
        ADDCOLUMNS (
            SUMMARIZE ( Dates, Dates[Month and Year] ),
            "@rev", [Total Revenue]
        ),
        [@rev]
    ),
    DATESINPERIOD ( Dates[Date], MAX ( Dates[Date] ), -3, MONTH )
)

danextian_0-1731540539562.png

danextian_1-1731540567096.png

 

Please see attached sample pbix for details.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Sahir_Maharaj
Super User
Super User

Hello @Anonymous,

 

Can you please try this approach:

3MonthRollingAverage = 
VAR CurrentDate = MAX('DateTable'[Date])
RETURN
    CALCULATE(
        AVERAGE('YourTable'[Price]),
        DATESINPERIOD('DateTable'[Date], CurrentDate, -3, MONTH)
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ About: https://sahirmaharaj.com/about.html
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors