Forum Discussion
Add and subtract from Running total
- 3 years ago
Try
Calculation = VAR T = ALL ( 'All Web Site Data (2)' ) VAR T1 = TOPN ( 4, T, 'All Web Site Data (2)'[TIMES], ASC ) VAR StartTime = MAXX ( T1, 'All Web Site Data (2)'[TIMES] ) VAR InService = MAXX ( T, 'All Web Site Data (2)'[EBS IN SERVICE] ) VAR Result = SUMX ( FILTER ( T, 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ), IF ( 'All Web Site Data (2)'[TIMES] > StartTime, 'All Web Site Data (2)'[Column1] - 'All Web Site Data (2)'[Column2] ) ) RETURN InService - Result
Thank you so much, I will try now. Is that one measure for both? Wouldn't i need two sepreate calculations? One for each yellow column ?
- Zidane223 years ago
Helper II
All good now thank you again.
- tamerj13 years ago
Community Champion
This is exactly what my proosed dax is doing. To eliminate the problem of the first row please try
Calculation =
VAR T =
ALL ( 'All Web Site Data (2)' )
VAR InService =
MAXX ( T, 'All Web Site Data (2)'[EBS IN SERVICE] )
VAR Result =
SUMX (
FILTER (
T,
'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] )
),
IF (
'All Web Site Data (2)'[Date] <> BLANK (),
'All Web Site Data (2)'[Column1] - 'All Web Site Data (2)'[Column2]
)
)
RETURN
InService - Result - tamerj13 years ago
Community Champion
Try
Calculation = VAR T = ALL ( 'All Web Site Data (2)' ) VAR T1 = TOPN ( 4, T, 'All Web Site Data (2)'[TIMES], ASC ) VAR StartTime = MAXX ( T1, 'All Web Site Data (2)'[TIMES] ) VAR InService = MAXX ( T, 'All Web Site Data (2)'[EBS IN SERVICE] ) VAR Result = SUMX ( FILTER ( T, 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ), IF ( 'All Web Site Data (2)'[TIMES] > StartTime, 'All Web Site Data (2)'[Column1] - 'All Web Site Data (2)'[Column2] ) ) RETURN InService - Result - Zidane223 years ago
Helper II
So it seems its calculating the same way your first forumla provided. It's not starting from the first value, which is currently 90, it's started from -4 : (
- tamerj13 years ago
Community Champion
Please try
RunningTotal =
VAR T =
ALL ( 'All Web Site Data (2)' )
VAR InService =
MAXX ( T, 'All Web Site Data (2)'[EBS IN SERVICE] )
VAR Result =
SUMX (
FILTER (
T,
'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] )
),
'All Web Site Data (2)'[Column1] - 'All Web Site Data (2)'[Column2]
)
RETURN
InService + Result - Zidane223 years ago
Helper II
Not sure.. it jumps to the 100's which dosen't make sense, should be counting down as they day goes on not counting up...
- tamerj13 years ago
Community Champion
Zidane22
Noted. Please tryRunningTotal = VAR T = ALL ( 'All Web Site Data (2)' ) VAR InService = MAXX ( T, 'All Web Site Data (2)'[EBS IN SERVICE] ) VAR Result = SUMX ( FILTER ( T, 'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) ), 'All Web Site Data (2)'[Column1] - 'All Web Site Data (2)'[Column2] ) RETURN InService - Result - Zidane223 years ago
Helper II
So if you look at the table above, the first item is 90 (not sure why there is a zero) but the value 90 updates through powerautomate depending whats in service. So if we only have 90 trucks in service we go over this, it should go into the negtives and not to 100's. Like the number will always be beloew the 90 or what ever value is there . so starting number of this forumla should start at 90 then gose down as the day goes because we are actually using trucks, if it goes into the minus means we are short then by the end of the day the number should go back up with all the returns