Moving Average different Values

Simple Moving Average.pbix (181.9 KB)

Hi Experts,
Can you please please advise and guide me why the moving average gives different result if Calculate is used in SUM and only SUM alone.
Below screenshots are for reference and attached PBIX file for your reference.

Hello @EnanBahadur

Thank you fo shaing your question here

So for better understanding, I duplicaetd your graphs and converted the to a table for better understanding :

and immidiately its visible that second table where you are not using Calculate, gives incorrect answer. and the Key here is the Context Transition. a Key concept in DAX.

AverageX is an itirator function, and when Calculate is used inside of an itirator function, it implements context transition. this is not happening in the second measure

Best way to not incur this situation is to use a measure that calculates sum(GME_Stock_History[Close]).

This measure will work because a measure is always wrapped inside of a calculate as a default property.

I hope this helps.

Regards
Japjeet

Thanks a lot @jsodhi for your guidance.