Forum Discussion
topazz11
Helper III
8 months agodaily variance in DAX
How do I calculate the variance as below? ---i tried to write it and doesnt work. Daily Variance = VAR _maxvalue = CALCULATE ( MAX ( table[Value] ), FILTER ( table, table[Date] ...
- 8 months ago
topazz11 I think that the following should work:
Daily Variance = VAR _CurrentDate = MAX( 'Table'[Date] ) VAR _PreviousDate = CALCULATE( MAX( 'Table'[Date] ), 'Table'[Date] = _CurrentDate - 1 ) VAR _CurrentValue = MAX( 'Table'[Value] ) VAR _PreviousValue = CALCULATE( MAX( 'Table'[Value] ), 'Table'[Date] = _PreviousDate ) VAR _Return = IF( _PreviousDate = BLANK(), 0, _CurrentValue - _PreviousValue ) RETURN _Return
GeraldGEmerick
Memorable Member
8 months agotopazz11 I think that the following should work:
Daily Variance =
VAR _CurrentDate = MAX( 'Table'[Date] )
VAR _PreviousDate =
CALCULATE(
MAX( 'Table'[Date] ),
'Table'[Date] = _CurrentDate - 1
)
VAR _CurrentValue = MAX( 'Table'[Value] )
VAR _PreviousValue =
CALCULATE(
MAX( 'Table'[Value] ),
'Table'[Date] = _PreviousDate
)
VAR _Return = IF( _PreviousDate = BLANK(), 0, _CurrentValue - _PreviousValue )
RETURN _Return