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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jinxiang
New Member

Moving average using variable table

Dear all,

 

I'm new to Power BI and this community. While exploring how to calculate moving average of a simple dataset, I came across an unexpected result that I could not explain.

The data is simple: a sales table with an amount and date column. I subsequently created a calendar table and did a moving average calculation (found online, see green box below). However, when the "summarize" part of the code was brought out as a variable, the calculation gave an unexpected result (see red box below).

Presentation1.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

However, i'm not sure the second measure gave unexpected values.

Any pointers or link to the relevant topic of why this is so, will be greatly appreciated.

Thank you very much!

Rgds,
Jinxiang

1 REPLY 1
lbendlin
Super User
Super User

The difference comes from the way CALCULATE and SUMMARIZE interact.  

 

Here's an excellent article that describes the basic idea

https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.