How to calculate difference between to cumulative sums?

So in my project I have mock bank account transaction data and I'm trying to calculate the difference between two cumulative sums. I don't know if I'm going about this the right way but what I'm doing is for each day in the span of a year, I'm calculate the cumulative sum of two number fields, debit and credit. I want to figure out how to subtract the cumulative sum of debit from the cumulative sum of credit.

CumulativeDifference = CumulativeSumCredit - CumulativeSumDebit.

The main goal I'm trying to achieve is to see the balance of the bank account according to the analyzed transaction data, but I just can't seem to get there.

Any help would be appreciated, thanks in advance :slight_smile:

1 Like

Use the timelion visualization to graph arithmetic on aggregated results.

It's not possible in the core Kibana visualizations, but you could use Timelion or Time Series Visual Builder to accomplish this.

The Timelion expression would look like this:

.es(*, metric=sum:credit).cusum().subtract(.es(*, metric=sum:debit).cusum())

In TSVB it would look like this:

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