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

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

Reply
Anonymous
Not applicable

Dynamic Moving Average per Day based on multiple values

Hi All,

 

I am trying to achieve a Moving Average per Day with a dynamic adjustment. My issue is that I have multiple values per day and seem to be struggling with that. I have already made a moving average based on individual values but I also need the one based on Day.

 

Currently what I have is a table ('TBUData') like this:

Josh_M_4-1686556243957.png

The moving Average works when its individual days but when I vary it to more than one it doesn't seem to be doing the right calculation (4 Day set to parameter):

Josh_M_5-1686556265015.png

My Measure calculation is this:

Moving Avg Per Day = 
//Selecting the date in the range
VAR _LastDate =
MAX (TBUData[Date])
//Defining the duration to be considered for average calculation(k)
VAR _Duration = [Parameter By Day]
//Filtering the Calendar Table for the defined range
VAR _CalculationPeriod =
FILTER (
ALL ( TBUData),
AND (
TBUData[Date] > _LastDate - _Duration, 
TBUData[Date] <= _LastDate 
)
)
//Calculating the Moving Average
VAR _MovingAverage =
IF (
COUNTROWS ( _CalculationPeriod ) >= _Duration, 
CALCULATE (
AVERAGEX(TBUData,[M2Average]), 
_CalculationPeriod
)
)
RETURN
_MovingAverage

 

For relationships I also have master date table although I am just trying to get it to work with the current table for now:

Josh_M_3-1686556148788.png

Any help would be appreciated 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try a measure like with help from date table

 

4 Day Avg = CALCULATE(AverageX(Values('Date'[Date]),calculate(Sum('Table'[Value])))
,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-4,DAY))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak, I have tried it like that few times but it just shows blank even though I know the relationship works through other plots

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.