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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JohnFabric
Helper I
Helper I

Issue with rolling average based off item type

Hello, I'm looking to create a rolling 90 day/3 month average of LeadTime over the course of a year. This is what my data looks like

 

JohnFabric_0-1736472239668.png

The issue with this is I have three different WorkItemType values: "Task", "Feature" and "PBI" so even though all the data is in a single table, I need three different rolling averages, one per type.

 

The DAX I have so far is for a single type, Feature. I assume I will need 3 measurements in total, one for each.

Rolling Average = VAR LastTransactionDate = MAX('Query1'[CompletedDateSK])
VAR AverageDay = 90
VAR PeriodInVisual = 
FILTER(
    ALL(
        'Query1'[CompletedDateSK]
    ),
    AND(
        'Query1'[CompletedDateSK] > LastTransactionDate - AverageDay,
        'Query1'[CompletedDateSK] <= LastTransactionDate
    )
)
VAR WorkItemType =
FILTER(
    ALL(
        'Query1'[WorkItemType]
    ),
    AND(
        'Query1'[WorkItemType] = "Feature",
        'Query1'[WorkItemType] = "Feature"
    )
)
VAR OutPut =
CALCULATE(
    AVERAGEX(
        'Query1',
        [LeadTimeDays]
    ),
    PeriodInVisual, WorkItemType
)
RETURN
OutPut

Which feels like it can be improved. I'm also not sure it is calculating the right values either, since the rolling average is being calculcated as the same as the month average

JohnFabric_1-1736472578301.pngJohnFabric_2-1736472590209.png

How can I calculate rolling average correctly given my data?

 

Thanks!

1 ACCEPTED SOLUTION
adudani
Super User
Super User

hi @JohnFabric 

 

This reference shows how to use concat to check if the moving average is calculated as expected.
How to Calculate Moving Averages in Power BI - The Ultimate Guide

 

you can modify the "Dates in period" part of the DAX code to put in the required MA period.

Lastly, if you apply a visual level filter using Workitem Type  on the matrix, you could have 3 visuals filtered with the same DAX code. 

 

hope this helps. let me know if this resolves the issue. 

 

if it doesn't, kindly upload a sample input (masking sensitive information)  in a usable format such as table, csv, excel etc. and a sample output.

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,
Avinash

View solution in original post

2 REPLIES 2
adudani
Super User
Super User

hi @JohnFabric 

 

This reference shows how to use concat to check if the moving average is calculated as expected.
How to Calculate Moving Averages in Power BI - The Ultimate Guide

 

you can modify the "Dates in period" part of the DAX code to put in the required MA period.

Lastly, if you apply a visual level filter using Workitem Type  on the matrix, you could have 3 visuals filtered with the same DAX code. 

 

hope this helps. let me know if this resolves the issue. 

 

if it doesn't, kindly upload a sample input (masking sensitive information)  in a usable format such as table, csv, excel etc. and a sample output.

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,
Avinash

Thanks, I was able to figure this out based on the video. I needed to change my formula. Each time I listed

 

Query1'[CompletedDateSK]

I needed to change it to

Query1'[CompletedDateSK].[Date]

That correctly calculated a 90 day average. Then I created 3 measurements and got them all displayed correctly

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.