fbaligand / kibana-enhanced-table

Kibana visualization like a Data Table, but with enhanced features like computed columns, filter bar, and “Split Cols” bucket
Apache License 2.0
309 stars 64 forks source link

Add computed row or use a formula when using SHOW TOTAL #206

Closed ashryverrr closed 2 years ago

ashryverrr commented 3 years ago

Hi,

I'm using Kibana 7.10 and I have a question regarding computed columns:

I've added the Show Total (SUM function) and I added a computed column which computes the variance between 2 values.

image

Now, in the Total Sum row instead of the Variance column being the total Sum of the variances above, is there any way that I can also use a formula to get the variance of the TOTAL SUM row by using a formula? Because what it's currently doing is adding all of the Variance which makes sense since the function is SUM.

Also, thank you for this wonderful plugin.

Best regards

fbaligand commented 3 years ago

Hi,

you can do that, by checking “compute column total using formula” in your computed column settings.

ashryverrr commented 3 years ago

Hi Fabien,

I just tried it but it doesn't seem to be working. The computed column is not showing the Total which is supposed to be calculated using the formula, it's just blank on my end.

image

fbaligand commented 3 years ago

@ashryverrr Could you paste here a screenshot of your computed column settings? By the way, do you use a "Split cols" bucket?

ashryverrr commented 3 years ago

Yes, I'm using "Split cols" bucket. Here is the screenshot of the computed column: image

fbaligand commented 3 years ago

OK. Could you try this formula : (col(3, 0) - col(2, 0)) / col (2, 0.01)

ashryverrr commented 3 years ago

That worked - thank you! Can you explain why my original formula didn't work and why this one did? I want to understand in case, I have other kind of scenario like this one. 👍

fbaligand commented 3 years ago

Nice to see that it works!

I think that your column labels are numbers and not strings. And so, col() function does not find the column when it searches with a string value. then, it is important to not divide by 0.

ashryverrr commented 3 years ago

Hi Fabien,

Sorry to re-open this but I tried doing the same thing now with strings as the title column but it still doesn't show the total based on the formula.

This is my computed formula settings:

image

Below is the output:

image

Any idea or it might be a bug? Thank you in advance.

fbaligand commented 3 years ago

Well, I just tried to reproduce your issue. And I get also a buggy result. My result seems to be a bit different, because I get 0% as total. I will try to fix the bug in a next release.

Waiting this, here's a workaround that works for my test: ((col(2, 0) * 2) - col(1, 0)) / col(1, 0.1)

That is to say: use column indices to reference columns instead of column labels.

fbaligand commented 2 years ago

Great news: Enhanced Table v1.13.0 is out with this issue fixed! Numerous other enhancements are also available.

Check it there: https://github.com/fbaligand/kibana-enhanced-table/releases/tag/v1.13.0