Forum Discussion
Cumulative Total for timestamp
- Anonymous1 year ago
Hi azakir ,
I create a table as you mentioned.
Then I create some calculated columns and measures.
Here are calculated columns DAX codes:
Hour = HOUR('Table'[Timestamp])HourlyBin = 'Table'[Timestamp] - SECOND ( 'Table'[Timestamp] ) * ( 1 / 86400 ) - MINUTE ( 'Table'[Timestamp] ) * ( 1 / 1440 )IncrementPerHour = DIVIDE(43626,12)Here are measures DAX codes:
TargetRunningSum = VAR StartTime = TIME(18,0,0) VAR CurrentTime = MAX('Table'[HourlyBin]) VAR _Incremental = MAX('Table'[IncrementPerHour]) RETURN IF(CurrentTime >= StartTime, (DATEDIFF(StartTime, CurrentTime,HOUR)+1) *_Incremental , BLANK() )CumulativeSum = CALCULATE( SUM('Table'[Value]), FILTER( ALLSELECTED('Table'), 'Table'[HourlyBin] <= MAX('Table'[HourlyBin]) ) )Finally when you add columns you want, you will see what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi azakir ,
I create a table as you mentioned.
Then I create some calculated columns and measures.
Here are calculated columns DAX codes:
Hour = HOUR('Table'[Timestamp])HourlyBin =
'Table'[Timestamp]
- SECOND ( 'Table'[Timestamp] ) * ( 1 / 86400 )
- MINUTE ( 'Table'[Timestamp] ) * ( 1 / 1440 )IncrementPerHour = DIVIDE(43626,12)
Here are measures DAX codes:
TargetRunningSum =
VAR StartTime = TIME(18,0,0)
VAR CurrentTime = MAX('Table'[HourlyBin])
VAR _Incremental = MAX('Table'[IncrementPerHour])
RETURN
IF(CurrentTime >= StartTime,
(DATEDIFF(StartTime, CurrentTime,HOUR)+1) *_Incremental ,
BLANK()
)CumulativeSum =
CALCULATE(
SUM('Table'[Value]),
FILTER(
ALLSELECTED('Table'),
'Table'[HourlyBin] <= MAX('Table'[HourlyBin])
)
)
Finally when you add columns you want, you will see what you want.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- azakir1 year agoResolver I
Hi Anonymous This has resolved the issue. Thank you for explaining in such a detail.