TSVB derivative returns 0 if previous interval was 0

This dataset has values recorded on a Monday to Friday, and no data at weekends. The graph plots data per day/24 hours.

I've plotted a cumulative sum (blue line) and the value changes each weekday; as there is no data recorded on a Saturday or Sunday, the metric drops to 0 at weekends (as expected).

However, a derivative metric (the pink bars) will only get plotted on a Tuesday to Friday. The highlighted day is a Monday and as you can see the pink bar derivative is 0.

I'd like to get the pink bars plotting for Mondays. An option that I can see would be to plot some summary values on a Saturday and Sunday to match Friday's final values - would there be an automated way to do this? I don't think a transform would work?

Are there any other ideas how to get the derivative bars to plot when the previous intervals' data is 0?

TIA
Mark

Hello Mark, the setup is not fully clear to me. Often, one would have a baseline time series, and in addition to that, perhaps a difference (what Elasticsearch calls derivation). However you're making a reference to a cumulative sum (blue line). So, do you have a baseline time series, which you don't show, and two derived ones, a difference and a cumulative sum? Have you a screenshot of the full config?

Hey Robert,

Yes, I have a baseline time series - not shown on the graph - and two derived metrics: first is a bucket script (containing a cumulative sum) and then summed in a Series Aggregation, and then the second in the screenshot is a derivative based on the cum sum.

I'm trying to solve with a Timelion graph - this formula below gives me 75 lines, but I cannot sum the 75 lines into 1 line using .sum() (the equivalent of the Series Aggregation in the TSVB graph). Any thoughts there?

Thanks Robert!

    .es(index=daily_summary_alpaca,timefield=recv_timestamp,metric=sum:buy_filled_size,split=instrument:100).cusum().subtract(
.es(index=daily_summary_alpaca,timefield=recv_timestamp,metric=sum:sell_filled_size,split=instrument:100).cusum())
.multiply(.es(index=daily_summary_alpaca,timefield=recv_timestamp,metric=avg:latest_price,split=instrument:100))

Thanks for the added detail, Duncan, I understand your setup better now. Why do you say in your original post that the drop of the blue cumulative sum to zero at weekends is "as expected"? Is it not your expectation that as the base metric is zero, the cumulative sum stays level? I see on the chart that both the cumulative sum and the daily difference are zeros on weekends, which wouldn't be my expectation unless Friday already had a metric value of zero and a cumulative sum of also zero.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.