SUMX vs row by row multiplication

I have an issue using SUMX and simple multiplication of row by row.
I have the following table
image .
The column Estimated_number_of animal_fed_by_Purina is


and the column Ingredient _Tons x Number_of_Head_fed_per_year_per_ton is
image

I would assume that these two columns would give me the same results, but they are not.
why is that? thank you

Hi,

Unless you exactly know what you are doing, I would suggest avoiding including measures into iterator functions as this causes what we call context transition. As a result, your SUMX may not behave as you would expect.

Regards,

DiBest

HI @gusdcruz,

Your 2nd formula is not correct as the first argument of SUM does not do context transition. So, in every row, it will multiply [Total SUM] with your measure instead of sum of that row.

You can watch below video to understand context transition. I believe if you simply wrap first argument of 2nd formula around calculate, it will give same result. Calculate will just do context transition.

Try like : Calculate(SUM(‘Dairy_Selenium’[Ingredient_Tons]))*[Number_of_head_fed_per_year_per_ton]

Check out these videos below to understand the difference a bit better

It’s all about the context created within the formula.

I also wouldn’t place multiplication inside a SUM. You would rather place the multiplication outside the sum.

E.g.

=SUM( columnname) * measure

Thanks
Sam

Hi @gusdcruz, we’ve noticed that no response has been received from you since the 28th of February. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. You may reopen a new thread when the need arises.

Thanks everyone for the helpful information and the videos, I have watched all of them and in my case I will use SUMX.