Is it possible to calculate and plot max of two values in grafana elasticsearch?

I have data of following format…
Timestamp,a, a_minus_alast,max(0,a_minus_alast)

Columns timestamp and a are stored in elasticsearch…a_minus_alast is derived by using current value of a in given row minus a value in previous row. Max(a_minus_alast,0) is also derived accordingly…

Want to plot max(a_minus_alast,0) against timestamp at a given moment…

Wanted to know if there are any inbuilt functions provided by elasticsearch and grafana with which I can derive a_minus_alast and max of a_minus_alast and zero…I guess influxdb provides some function like non_negative_difference to achieve same. Want to implement similar using elasticsearch…

Thanks for any help.

There is a derivative function available in Grafana (which is a native ES function) but not a non-negative.