Hi,
I'm creating a dashboard and now I need to show the unitary value of the products, this value must be dynamical along the time, the unitary value must be calculated adding all the prices and adding all the units to divide later, I had created a query in Elasticsearch that calculate the thing that I need. The problem is I don't know how to show the result in Kibana
{
"size": 0,
"query": {
"range": {
"@timestamp": {
"gte": "2021-01-01",
"lte": "2021-02-08"
}
}
},
"aggs": {
"Prducts": {
"terms": {
"field": "reg_nr.keyword",
"size": 10
},
"aggs": {
"total_unit": {
"sum": {
"field": "pesoneto"
}
},
"total_flete": {
"sum": {
"field": "fletetot"
}
},
"UnitaryValue": {
"bucket_script": {
"buckets_path": {
"unit": "total_unit",
"total": "total_flete"
},
"script": {
"source": "(params.total / params.unit)"
}
}
}
}
}
}
}