Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Month over month calculation in visualizations #35043

Closed
AlonaNadler opened this issue Apr 13, 2019 · 6 comments · Fixed by #101718
Closed

Month over month calculation in visualizations #35043

AlonaNadler opened this issue Apr 13, 2019 · 6 comments · Fixed by #101718
Labels
enhancement New value added to drive a business result Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@AlonaNadler
Copy link

Often users want to compare in percentage between different time ranges, e.g. this month and previous month M/m or D/d to understand hows the change in the value of a specific metric as a percentage of the previous month’s value. (This_month - Last_month)/Last_month
This is currently possible in TSVB but not very straightforward using serial difference and bucket script aggregations
image

Provide an easy way in Kibana to visualize M/m in percentage where the users can define what is the interval which they want to compare (day, month, years, dynamic) and based on which metric (sum(revenue), average (bytes)

Below how can this be done in TSVB
image

@timroes timroes added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Apr 16, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@polyfractal
Copy link
Contributor

The MovingFunction pipeline agg could do this a bit easier than serial-diff/bucket_script.

  • window: 2 to get two values
  • shift: 1 to shift the window so that it includes "current" and "current - 1" bucket values
  • script to perform the month-over-month calculation

@AlonaNadler
Copy link
Author

do this a bit easier than serial-diff/bucket_script.

is it easier because it uses only one function? or is it better from a performance perspective? or maybe something else :)

@polyfractal
Copy link
Contributor

Easier because it's only one function, and essentially what moving_function was designed for (generating a metric based on a sliding window of buckets). Also keeps the response JSON tidier since you'll have the metric of interest directly and on "intermediate" steps.

Probably not relevant for this feature, but the other advantage is that moving_function allows different windows of time, not just the last month.

Pipeline aggs are essentially free (relatively speaking) since they are all "post-processing" events after the data has been aggregated, so performance between the two is negligible for the most part.

@wylieconlon
Copy link
Contributor

I've looked into this a bit, and think this is part of a broader group of "time-shifted" comparisons. It's actually really similar to another discussion we've had about how to support cumulative sum with a starting value, and I built support for that into my recent spacetime project. The way it works is by letting users select a "relative time range" for each layer, and then having a way to compare the two layers:

Screenshot 2020-06-05 16 14 32

The main benefit of this approach is that you can look at numbers over two completely separate time periods, for example "hourly metrics today vs hourly metrics one week ago today". Also, it scales to other types of queries.

@wylieconlon
Copy link
Contributor

This implementation depends on how Lens will implement time offsets in general- there's a proposal for the general feature in that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants