Forum Discussion
LAG Conversion from MDX to DAX
- Anonymous4 years ago
Hi GillyGils ,
If there are only 'End of Month Dates' in your fact table. Please have a try.
Create a measure.
Measure1 = VAR _date = MAX ( 'Table'[date] ) VAR _pre_date = EOMONTH ( _date,-1) VAR _value = CALCULATE ( [total available], FILTER ( ALL ( 'Table'), 'Table'[date] = _pre_date ) ) RETURN _valueBest Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Polly,
The code you provided is working for me as expected. I had use to EOMONTH, as I only have 'End of Month Dates' in my fact table:
Measure =
VAR _date =
MAX ( 'Table'[date] )
VAR _pre_date =
EOMONTH ( _date, -1 )
VAR _value =
CALCULATE (
[total available],
FILTER ( ALL ( 'Table'[date], 'Table'[total] ), 'Table'[date] = _pre_date )
)
RETURN
_value
One quick additonal question, when I drag in a Date Hierarchy of Time Dimension, the values are then empty:
Do I add another FILTER conidition to the DAX query?
Thanks
- Anonymous4 years agoNot applicable
Hi GillyGils ,
If there are only 'End of Month Dates' in your fact table. Please have a try.
Create a measure.
Measure1 = VAR _date = MAX ( 'Table'[date] ) VAR _pre_date = EOMONTH ( _date,-1) VAR _value = CALCULATE ( [total available], FILTER ( ALL ( 'Table'), 'Table'[date] = _pre_date ) ) RETURN _valueBest Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- GillyGils4 years agoFrequent Visitor
Thank you Polly. This works perfectly.
Still getting a hang of the DAX syntax and this is helping me understand it more.Thank you.