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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JohnFabric
Frequent Visitor

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.