Forum Discussion
Hansolu
Helper II
10 months agoUnderstanding variable calculation
HI I am running into an issue understanding the variables behavior. Once i use a var to make my formula more dynamic, the totals are screwed up BASE: usage = SUMX ( fact_bom, fact_bom[TotalQty]* ...
- 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
)
Kedar_Pande
Super User
10 months agoVariables 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
)