Forum Discussion
DAX New Column Error - not enough memory
- 2 years ago
zenz - Instead of a column, you could create this as a measure. The DAX needs to change slightly, but the below should work for you:
VAR _id = SELECTEDVALUE ( 'Table (7)'[id] ) VAR next_date = SELECTEDVALUE ( 'Table (7)'[date] ) + 1 VAR current_date = SELECTEDVALUE ( 'Table (7)'[date] ) VAR id_next = CALCULATETABLE ( VALUES ( 'Table (7)'[id] ), REMOVEFILTERS ( 'Table (7)' ), 'Table (7)'[date] = next_date, 'Table (7)'[id] = _id ) VAR max_date = CALCULATE ( MAX ( 'Table (7)'[date] ), REMOVEFILTERS ( 'Table (7)' ) ) RETURN SWITCH ( TRUE (), _id IN id_next, 0, current_date = max_date, 0, NOT ( _id ) IN id_next, -1 )Screenshot below shows it's working for me:
If this works for you, please mark it as the solution.
- 2 years ago
zenz - Please remember to accept this as the solution, it helps others learning DAX find answers to their problems.
zenz - Instead of a column, you could create this as a measure. The DAX needs to change slightly, but the below should work for you:
VAR _id =
SELECTEDVALUE ( 'Table (7)'[id] )
VAR next_date =
SELECTEDVALUE ( 'Table (7)'[date] ) + 1
VAR current_date =
SELECTEDVALUE ( 'Table (7)'[date] )
VAR id_next =
CALCULATETABLE (
VALUES ( 'Table (7)'[id] ),
REMOVEFILTERS ( 'Table (7)' ),
'Table (7)'[date] = next_date,
'Table (7)'[id] = _id
)
VAR max_date =
CALCULATE ( MAX ( 'Table (7)'[date] ), REMOVEFILTERS ( 'Table (7)' ) )
RETURN
SWITCH (
TRUE (),
_id IN id_next, 0,
current_date = max_date, 0,
NOT ( _id ) IN id_next, -1
)Screenshot below shows it's working for me:
If this works for you, please mark it as the solution.
thank you so much. You are super start!.
This should solve another question I had for you. really apprecitate it!
- mark_endicott2 years agoSuper User
zenz - Please remember to accept this as the solution, it helps others learning DAX find answers to their problems.