Forum Discussion
dpc_development
Helper III
7 years agoNeed help with iterative measure
I have a model with three columns - list_id, sequence, daily_return. Basically, for each list_id, there is a sequence of numbers from 0 onwards (0, 1, 2, ..., X) with different percentage values in ...
- 7 years ago
EDIT: Posted the below before seeing your post. Looks like you have a solution already.
Thanks for that :)
So you basically want to replace the return with zero for the first id in the context of the overall filters, but thereafter use the return from the table. You were on the right track with the code snippet you just posted, but I have defined min_id_allselected which gives the min_id for the current list (i.e. max_list).
This measure worked for me. There are potentially different ways you could write this but it should do the trick:
current_cumulative_return = VAR max_list = MAX ( 'CMC Daily Return'[list_id] ) VAR max_id = MAX ( 'CMC Daily Return'[id] ) VAR min_id_allselected = CALCULATE ( MIN ( 'CMC Daily Return'[id] ), 'CMC Daily Return'[list_id] = max_list, ALLSELECTED ( 'CMC Daily Return' ) ) RETURN CALCULATE ( PRODUCTX ( 'CMC Daily Return', 1 + IF ( 'CMC Daily Return'[id] = min_id_allselected, 0, 'CMC Daily Return'[daily_return] ) ), 'CMC Daily Return'[list_id] = max_list, 'CMC Daily Return'[id] <= max_id, ALLSELECTED ( 'CMC Daily Return' ) )Regards,
Owen
dpc_development
Helper III
7 years agoHaha! You posted your final one measure solution before I was finally able to figure it out. Thanks for helping me get there.
dpc_development
Helper III
7 years agoHi OwenAuger, can you please help me with another question?