I have this index:
PUT sales
{
"settings": {
"index": {
"number_of_shards": 3,
"number_of_replicas": 0
}
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"product": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"volume": {
"type": "float"
},
"cost": {
"type": "float"
}
}
}
}
POST sales/_doc
{
"product": "Product 1",
"volume": 4,
"cost": 3
}
POST sales/_doc
{
"product": "Product 1",
"volume": 10,
"cost": 3
}
I want to calculated the cost average based on volume.
If I have this 2 docs, I have to calculate like this:
=(sum(cost * volume))/sum(volume)
=(3 * 4 + 3 * 10) / 10 +4
How can I do this on a kibana Data Table?
I want the table like this:
Product_____| Average
Product 1 | 8.2