Forum Discussion
How to do a double For/While?
- 4 years ago
Hi Anonymous,
If you would like to achieve the desired result with a DAX formula, you may try this Measure.
Avg = VAR avg_ = CALCULATE ( AVERAGE ( 'Table'[Points] ), FILTER ( ALL ( 'Table' ), 'Table'[Iteration] >= MAX ( 'Table'[Iteration] ) && 'Table'[Iteration] < ( MAX ( 'Table'[Iteration] ) + 3 ) ) ) VAR maxIndex = CALCULATE ( MAX ( 'Table'[Index] ), ALL ( 'Table' ) ) RETURN IF ( MAX ( 'Table'[Index] ) > maxIndex - 2, BLANK (), avg_ )Then, the result looks like this.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun
Hi Anonymous,
If you would like to achieve the desired result with a DAX formula, you may try this Measure.
Avg =
VAR avg_ =
CALCULATE (
AVERAGE ( 'Table'[Points] ),
FILTER (
ALL ( 'Table' ),
'Table'[Iteration] >= MAX ( 'Table'[Iteration] )
&& 'Table'[Iteration]
< ( MAX ( 'Table'[Iteration] ) + 3 )
)
)
VAR maxIndex =
CALCULATE ( MAX ( 'Table'[Index] ), ALL ( 'Table' ) )
RETURN
IF ( MAX ( 'Table'[Index] ) > maxIndex - 2, BLANK (), avg_ )
Then, the result looks like this.
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please let me know. Thanks a lot!
Best Regards,
Community Support Team _ Caiyun