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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cztmm
Regular Visitor

Moving Average KPI YTD and MTD

Hi all,

 

I am trying to work on a visual to track the change in our task completion durations through our reporting year and month and compare it to a target. We want to visualise the average duration when we complete a task and compare this with the movement throughout the year as historical average movement. The target for comparison differs based upon whether the task follows Process A (45) or Process B (90).

 

I previously calculated this using structured references in Excel offline, however these are unsupported in Office365. Using Excel to store this data is a bottleneck dependency which needs eliminating for wider service functionality. Therefore, I need to migrate this calculation for the visual into PowerBI or PowerQuery, either using DAX or M. I'm facing challenges when trying to calculate the moving averages and in getting them to display correctly in the visual. Due to company policies, I am unable to use custom visuals. 

 

  1. How can I accurately calculate the moving averages and display in a KPI visual with historical movement?
  2. How can I filter the measures to select a certain time frame without needing to alter the date range each month/year?
  3. How can I prevent the KPI measure from displaying (Blank) when there is not a task completed today?

Example data below:

 

ID Number (A)Process (B)Date Assigned (C)Date of Completion (D)Time to Complete (E)Year Average (F)Month of Completion (G)Month Average (H)Month Indicator (I)
1A26-Oct-2228-Nov-2233331133False
2A26-Oct-2213-Dec-224840.51248True
3A27-Jul-2203-Aug-22729.3333333387False
4A27-Jul-2214-Sep-224934.25949False
5A17-Aug-2230-Aug-221330810False
6A17-Aug-2226-Sep-224031.66666667944.5False
7B20-Oct-2203-Nov-2214141114False
8B24-Nov-2206-Jan-234328.5143False
9B21-Dec-2203-Jan-231323.33333333128False
10B23-Nov-2206-Dec-221320.751213True

 

  • Time to Complete is now calculated in PowerQuery (Date of Completion - Date Assigned)
  • Year Average was calculated in Excel using AVERAGEIF. It should be year to date (i.e. average of cumulative sum). Our reporting year is 1st October 2022 until 30th September 2023. The formula I used to calculate this in Excel was:

 

=AVERAGEIF($B$2:$B10,$B10,$E$2:$E10)​

 

  • Month of Completion was used to identify the Month in Month Average
  • Month Average should be the average of the cumulative sum in the Month to Date (e.g. if today is January, I want to have cumulative average for ongoing assignments coming in during January but also be able to look back at older months). The formula I used to calculate this in Excel was:

 

=AVERAGEIFS($E$2:$E10,$B$2:$B10,$B10,$G$2:$G10,$G10)​

 

  • Month Indicator was used to control the MTD KPI visuals to display last month (e.g. December if today is January) - this is probably unnecessary now.

I think that the method I used to calculate averages previously was inaccurate, as it was dependant on date-order being correct. In the example data above, task 9 would not be included in calculating the average for January when assessing task 8.

 

The KPI visuals I was driving with Excel-based calculations looked like this:

cztmm_1-1675171286838.pngcztmm_0-1675171241040.png

Any support you can offer would be greatly appreciated!

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.