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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
aar0n
Advocate II
Advocate II

Calculation of Moving Average depending on the date and other value in the same row

Hi, I have a similar problem to the following:

 

https://community.powerbi.com/t5/Desktop/Calculation-of-Moving-Average-depending-on-the-date-and-oth...

 

The biggest difference that I could not figure out, is that i want the average to be for every value before the current row (whereas in the above example, it is for a 30-day timeframe).

 

Thank you

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@aar0n ,

 

You need to add an index column and then create a calculate column using DAX like pattern below:

AverageCol =
CALCULATE (
AVERAGE ( TableA[SALES] ),
FILTER (
TableA,
TableA[SKU] = EARLIER ( TableA[SKU] )
&& TableA[Index] <= EARLIER ( TableA[Index] )
)
)

 

Community Support Team _ Jimmy Tao

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

1 REPLY 1
v-yuta-msft
Community Support
Community Support

@aar0n ,

 

You need to add an index column and then create a calculate column using DAX like pattern below:

AverageCol =
CALCULATE (
AVERAGE ( TableA[SALES] ),
FILTER (
TableA,
TableA[SKU] = EARLIER ( TableA[SKU] )
&& TableA[Index] <= EARLIER ( TableA[Index] )
)
)

 

Community Support Team _ Jimmy Tao

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.