Forum Discussion
Understanding variable calculation
- 10 months ago
Variables are calculated once per row context in SUMX, not once per entire measure. Your issue is that [m_fcst_qty_erp] is being evaluated outside the row context.
Fix it by moving the variable inside SUMX:
usage dynamic =
SUMX(
fact_bom,
VAR _base = [m_fcst_qty_erp]
RETURN
fact_bom[TotalQty] * _base
)
Hi,
I tried to create a table to briefly explain how two measures work.
Please check the below picture, and I hope it helps.
Because, VAR is calculated once inside the measure, when it comes to the total row context, VAR is calcualted as 27.
- Hansolu10 months agoHelper II
HI
thanks for the explanation, however i am still confused.
I thought SUMX is kind of store the row results and at the total level it is summing up all stored results.
In my simple example, I can not use var for one element of the calculation inside the sumx as the total would be always wrong?