Visualize day between two dates on kibana

I have date with following fields

    ...
    ...
    branch_id: 909
    agent_id: 909A01234
    first_call_date: date A, can be empty (no call made yet)
    final_call_date: date B, can be empty (no call made yet)
    ...
    ...

I want to visualize min, max, and average(days between first_call_date and final_call_date, group by branch. I'm thinking of having line chart where x axis is branch_id. The question is: how can I calculate days between those two days? I don't see any math function during visualization creation.

Thank you

Hi,

You can use scripted fields here. Write a script to calculate the days between those two days - add it to a field and use that in visualization.

Thanks,
Bhavya

Thanks. I tried this, but does not success
doc['final_call_date'].value-doc['first_call_date'].value

Is there something I miss?

Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse date field [__missing__] with format [strict_date_optional_time||epoch_millis]"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"logstash-btpn-leads-2018.08","node":"e80Fgn8CRzSBR093BcXl2A","reason":{"type":"parse_exception","reason":"failed to parse date field [__missing__] with format [strict_date_optional_time||epoch_millis]","caused_by":{"type":"illegal_argument_exception","reason":"Parse failure at index [0] of [__missing__]"}}}]},"status":400}
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:712490
    at Function.Promise.try (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:503537)
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:502925
    at Array.map (<anonymous>)
    at Function.Promise.map (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:502883)
    at callResponseHandlers (http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:712068)
    at http://consul1.bfi.co.id/kibana/bundles/commons.bundle.js?v=16588:1:701418
    at processQueue (http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:132456)
    at http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:133349
    at Scope.$digest (http://consul1.bfi.co.id/kibana/bundles/vendors.bundle.js?v=16588:58:144239)

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