Forum Discussion
Anonymous
3 years agoNot applicable
Calculate with and without variables difference
I have 2 calculate formulas: Formula 1: Emp Exits = CALCULATE( SUM(Emp_Exits[Employee Exits]), Emp_Exits[MonthNo]<=MAX(Emp_Exits[MonthNo]), ALL(E...
- 3 years ago
Hi Anonymous
The measureEmp Exits with variable = VAR EmpExits = SUM ( Emp_Exits[Employee Exits] ) RETURN CALCULATE ( EmpExits, Emp_Exits[MonthNo] <= MAX ( Emp_Exits[MonthNo] ), ALL ( Emp_Exits[Month Name] ) )is exactly the same as
Emp Exits with variable = SUM ( Emp_Exits[Employee Exits] )The reason is that variables are only evaluated once therefore cannot be recalculated as measures inside a CALCULATE statement. Thus only the value of the first measure is always returned.
tamerj1
Community Champion
3 years agoHi Anonymous
The measure
Emp Exits with variable =
VAR EmpExits =
SUM ( Emp_Exits[Employee Exits] )
RETURN
CALCULATE (
EmpExits,
Emp_Exits[MonthNo] <= MAX ( Emp_Exits[MonthNo] ),
ALL ( Emp_Exits[Month Name] )
)
is exactly the same as
Emp Exits with variable =
SUM ( Emp_Exits[Employee Exits] )
The reason is that variables are only evaluated once therefore cannot be recalculated as measures inside a CALCULATE statement. Thus only the value of the first measure is always returned.