Forum Discussion
DouweMeer
Impactful Individual
2 years agoRunning total, Mono poly style
So, I have the problem that if you start of with, say, 200 and then per turn have the option to earn some or lose some, randomly at turn, for example, 50 or 67, you may hit rock bottom, lost all your...
- Anonymous2 years ago
Hi DouweMeer
Thanks for the reply from Sahir_Maharaj and Greg_Deckler , please allow me to provide another insight:
Please try this measure:
MEASURE = VAR _currentTurn = MAX ( 'Table'[Turn] ) VAR _vtable = ADDCOLUMNS ( SELECTCOLUMNS ( ALLSELECTED ( 'Table' ), 'Table'[Earn/ Loss], "_Turn", 'Table'[Turn] ), "_CurrentBN", ROUND ( SUMX ( FILTER ( ALLSELECTED ( 'Table' ), [Turn] <= EARLIER ( [_Turn] ) ), 'Table'[Earn/ Loss] ) / 200, 0 ) ) VAR _vtable2 = ADDCOLUMNS ( _vtable, "_previoudN", IF ( MAXX ( FILTER ( _vtable, [_Turn] = EARLIER ( [_Turn] ) - 1 ), [_CurrentBN] ) > [_CurrentBN], 1 ) ) VAR _vtable3 = ADDCOLUMNS ( _vtable2, "Sort", RANKX ( FILTER ( _vtable2, [_previoudN] <> BLANK () ), [_Turn],, ASC ) ) RETURN MAXX ( FILTER ( ADDCOLUMNS ( _vtable3, "_outcome", IF ( 200 + SUMX ( FILTER ( _vtable3, [Sort] = EARLIER ( [Sort] ) && [_Turn] <= EARLIER ( [_Turn] ) ), [Earn/ Loss] ) < 0, 0, 200 + SUMX ( FILTER ( _vtable3, [Sort] = EARLIER ( [Sort] ) && [_Turn] <= EARLIER ( [_Turn] ) ), [Earn/ Loss] ) ) ), _currentTurn = [_Turn] ), [_outcome] )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Sahir_Maharaj
Super User
2 years agoHello DouweMeer,
Can you please try the following:
Capital =
VAR StartCapital = 200
VAR RunningTotal =
CALCULATE(
SUM(TurnData[Earn_Loss]),
FILTER(
ALL(TurnData),
TurnData[Turn] <= MAX(TurnData[Turn])
)
)
VAR ResetCheck =
SUMX(
FILTER(
ALL(TurnData),
TurnData[Turn] <= MAX(TurnData[Turn])
),
[Earn_Loss]
)
RETURN
IF(
RunningTotal + StartCapital < 0,
StartCapital,
RunningTotal + StartCapital
)
- DouweMeer2 years ago
Impactful Individual
I'm not seeing within your measure at turn 8 the possibility for a third time a new starting capital. Wouldn't your measure do this?
Turn 1 2 3 4 5 6 7 8 9 Earn/ Loss 0 -20 -50 60 -250 0 -250 0 30 Running Total 0 -20 -70 -10 -260 -260 -510 -510 -480 Measure 200 180 130 190 200 200 200 200 200 Like, besides at 5 it should turn 0 instead of 200, but the running total just keeps counting after reset.