Forum Discussion

Hansolu's avatar
Hansolu
Helper II
10 months ago
Solved

Understanding 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]* ...
  • Kedar_Pande's avatar
    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
    )