Calculus between two fields

Hello,

I'm new to ES and Kibana and I think these are amazing tools ! However, I'm having a hard time making calculus on several values. Here is my problem : I'm making a website for a brand that has several shops, and I need to make a dashboard for them where they can see a percentage of difference in sales values between one specific shop compare to all the other shops. So I really need to make a calculus like : (global sales values – shop sales values) / sales values * 100.

Anyway I've searched a lot but I cannot really find the best way to do it. I'd love to use Timelion but in the end I only need a number displayed, not a whole chart. Should I use a script ?

Thanks a lot in advance if you take the time to help me, and please excuse my poor english skills.

You can achieve this by using TSVB (Time Series Visual Builder).

  1. Go to TSVB > Metric.
  2. Add the following type of aggregation to calculate the ratio between store sales and global sales (I used data from the eCommerce sample data set)

  1. Perform the remaining part of the calculation by adding am additional sub aggregation (by clicking on the small + icon in the right corner)

  1. Use the Options panel to adjust formatting, add a meaningful label.

Selection_162

  1. Voila!

Selection_163

Thanks a lot for your reply, this is exactly what I'm looking for.
I'm sorry but I'm not sure how to reach the type I'm looking for through the Numerator and Denominator fields. This is weird, because I have no problem with this in other Kibana visualizations. i.e, I would like to reach the "total" type in this document :

{
    "id": 52,
    "checkoutCompletedAt": "2018-11-29T16:15:25+01:00",
    "number": "000000031",
    "items": [
        {
            "id": 45,
            "quantity": 1,
            "unitPrice": 1713,
            "total": 1713

Sorry if it seems obvious, I'm having troubles using TSVB for now.

Hey florent,
Can you elaborate a little more on what exactly is not working for you, so I can test this?

Thanks a lot for answering. me I could finally find my issue with TSVB : the timerange I chose was not correct.
Now I'm trying to calculate a ratio in the same way with a boolean but I cannot make it work using "nameOfMyBoolean": true as a numerator and "nameOfMyBoolean": false. Is it possible to use booleans with TSVB ?

1 Like

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