Adding a new columns to a data table from a calculation based on two different columns in the same row

Hi,
The user wants to see if there is a way to add a two additional column (Calculated columns) to data table like below table.

Market | Total | D1 | D2 | Total D | Percentage D1 | Percentage D2 | percentage Total D
Source 10 3 3 6 ?? ?? ??
Target 15 4 9 13 ?? ?? ??


Total, D1 and D2 are coming as a count from aggregation columns from index .
Not sure how to generate percentage of D1,D2 and total D .

Can someone please help here

You can do this with scripted fields. You'll need to setup the fields ahead of time and then reference them in the visualization. https://www.elastic.co/guide/en/kibana/current/scripted-fields.html. There is no way to do this on the fly in a visualization itself. (Depending on the amount of data you're talking about it may be better to generate the fields on ingest rather than scripting on the fly)

Thank you Ben for the details. I am trying for percentile calculation .
For this, I have looped through the documents and taken total records . Another loop for conditional value from the total like success. Post to the values when i am trying to do percentile like below it is not working
percentile = ((100*success) / count);
Multiplication is working fine but division is not working. Any thoughts on this issue? Do we have any percentile operator for doing percentage calculation?

There is no percentage operator from the looks of it, https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-operators.html. I can't really help with the formula you provided as it doesn't seem to be complete and in the painless syntax.

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