cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Microsoft Employee

## Calculate moving average of a measure

Hi,

We have a table which calculates a measure per day based on the value of a few columns. Now we want to smooth out the measure  to show the trend over time. We tried to use the moving average formula and it throws error with aggregation function as only the table columns can be used there.

Is this even possible to do in power BI desktop? If not, we'll have to export the data out and caclulate somewhere else? Any ideas how to do this?

Thanks for any help on this.

-Amyee

4 REPLIES 4
Super User

@springday Read this post to get your answer quickly.  If you share some sample data, it will help to get you the solution.

Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤

Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Microsoft Employee

Here's the sample table.

Date                      ID        Level     Speed  Status

 1/28/2019 100 2380 34 1 1/28/2019 200 2198 29 0 1/28/2019 200 2198 35 1 1/28/2019 300 2115 46 0 1/28/2019 400 2396 22 1 1/28/2019 500 1438 12 1

dci = level/ ( median speed when status is 1 + median speed when status is 0)

Community Support

Hi @springday ,

Maybe you can try this measure:

``````dci =
VAR x =
CALCULATE(
MEDIAN(Sheet1[Speed]),
FILTER(
Sheet1,
Sheet1[Status] = 1
)
)
VAR y =
CALCULATE(
MEDIAN(Sheet1[Speed]),
FILTER(
Sheet1,
Sheet1[Status] = 0
)
)
VAR z =
CALCULATE(
x+y,
ALL(Sheet1[Level])
)
RETURN
DIVIDE(
MAX(Sheet1[Level]),
z
)``````

Best regards,
Lionel Chen

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

Microsoft Employee

Hmm..., it doesn't seem to sovle the moving average problem. Back to my original question, does Power Bi support moving average of a measure?

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.