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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello. I am new to Power BI desktop and trying to calculate a moving average of time series data but it is not correctly calculating using the sample code below. The calculcated time series data is the same as the source data and it is not averaging the 3 values as expected. The time series data is on a 5mins interval and would like to calculate the average over a 15mins period using 3 values from the source data.
Solved! Go to Solution.
Hi @Kade98002 - Filtering the DateTable to include only timestamps within the last 15 minutes. You can use DATEDIFF or simple time arithmetic with MAX(DateTable[DateTimeStamp]).
create a measure summing data directly, consider applying a row-level calculation instead
kWhIntervalTotal = SUMX(DeliveredkWh, DeliveredkWh[KWH])
main measure: updated
15MinskWDemand =
VAR MAXDATETIME = MAX(DateTable[DateTimeStamp])
VAR INTERVAL = [KWhIntervalPeriod]
VAR INTFILTER =
FILTER(
ALL(DateTable[DateTimeStamp]),
DateTable[DateTimeStamp] <= MAXDATETIME &&
DateTable[DateTimeStamp] > MAXDATETIME - TIME(0, 15, 0)
)
VAR OUTPUT =
CALCULATE(
AVERAGEX(DeliveredkWh, DeliveredkWh[KWH]),
INTFILTER
)
RETURN OUTPUT
Hope this works.
Proud to be a Super User! | |
Hi @Kade98002 - Filtering the DateTable to include only timestamps within the last 15 minutes. You can use DATEDIFF or simple time arithmetic with MAX(DateTable[DateTimeStamp]).
create a measure summing data directly, consider applying a row-level calculation instead
kWhIntervalTotal = SUMX(DeliveredkWh, DeliveredkWh[KWH])
main measure: updated
15MinskWDemand =
VAR MAXDATETIME = MAX(DateTable[DateTimeStamp])
VAR INTERVAL = [KWhIntervalPeriod]
VAR INTFILTER =
FILTER(
ALL(DateTable[DateTimeStamp]),
DateTable[DateTimeStamp] <= MAXDATETIME &&
DateTable[DateTimeStamp] > MAXDATETIME - TIME(0, 15, 0)
)
VAR OUTPUT =
CALCULATE(
AVERAGEX(DeliveredkWh, DeliveredkWh[KWH]),
INTFILTER
)
RETURN OUTPUT
Hope this works.
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 65 | |
| 44 | |
| 40 | |
| 29 | |
| 19 |
| User | Count |
|---|---|
| 200 | |
| 130 | |
| 102 | |
| 72 | |
| 55 |