kibana-enhanced-table icon indicating copy to clipboard operation
kibana-enhanced-table copied to clipboard

Can't sum up the values with top_hits aggragation

Open yjaigu opened this issue 3 years ago • 9 comments

Hi,

in Kibana 7.11.2 and kibana-enhanced-table v1.11.1, it doesn't sum up the values in a top_hit metric, aggregated with "concatenate" (with a simple split row bucket). Only "count" is actually working as a total function. It is annoying since I use the total of these columns to compute other colums total.

Example :

  • Metric
    • aggregation : top hit
    • field : a_numeric_field
    • aggregate with : Concatenate
    • Size : 1
    • Sort on : @timestamp
    • Order : descending
  • Split rows :
    • aggregation : terms
    • field : a_string_field
    • order by : alphabetical
    • order : descending
    • size : 5
  • Options :
    • Show total : checked

yjaigu avatar Apr 07 '21 17:04 yjaigu

Indeed, I reproduce the issue. I will try to fix it in next release.

fbaligand avatar Apr 09 '21 14:04 fbaligand

thanks Fabien !

Le ven. 9 avr. 2021 à 16:23, Fabien Baligand @.***> a écrit :

Indeed, I reproduce the issue. I will try to fix it in next release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fbaligand/kibana-enhanced-table/issues/201#issuecomment-816719399, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEN5TFUNILHM3DASS2L43TTH4EV7ANCNFSM42RFR5CA .

yjaigu avatar Apr 09 '21 14:04 yjaigu

Hi @fbaligand ,

This is still an issue in Opensearch 2.2.0.

I'm unable to sum Top hit aggregations whereas I'm able to do so in data table.

Data table: Data-table_total

Enhanced table: Screenshot 2022-11-30 at 2 04 30 PM

Need your help.

Sandy381 avatar Nov 30 '22 08:11 Sandy381

Well, I just did some tests, and I'm able to make it work: if field is numeric, and you use Average, Max, Min or Sum in "Aggregate with" setting, then Total feature works.

fbaligand avatar Nov 30 '22 12:11 fbaligand

@yjaigu @Sandy381 Could you try to use Average, Max, Min or Sum in “Aggregate with” setting?

fbaligand avatar Nov 30 '22 13:11 fbaligand

It works with Max, Min & Sum aggregations. No issues. For now I'm using Sum for my visualization & then put control filter visualization on top of my table visualization and filter as i need. But in some cases, I may want latest values. In this case it will not add up. Thanks for checking :)

Sandy381 avatar Nov 30 '22 13:11 Sandy381

Well, in "Top Hit" metric, if you set 1 in Size setting, whatever you use Average, Max, Min Sum or Concatenate aggregation, you will get exactly the same displayed result. Moreover, I just tested Data Table with a "Top Hit" metric with size=2 and Aggregate with=Concatenate. The total (sum) is the value of the first item, so it is wrong. It should be the sum of both items.

Demonstration with Data Table: image

fbaligand avatar Nov 30 '22 17:11 fbaligand

Hi Fabien, have you implemented the solution for this issue? I have the similar requirement . I am trying to create a metric visualization where I want to sum the top hits on an aggregation. I am using Kibana version 7.17 but I don't see the top hit option in 8.10 as well if I select bucket aggregation.

prakashgupta1605 avatar Nov 06 '23 06:11 prakashgupta1605

Hi, « top hit » aggregation is a « metric » aggregation, so you can’t use it in « bucket » aggregations. Then, as explained in previous comments, if you use top hit aggregation with size=1 and function=max, then the « total » feature will work.

If it still not works for you, could you share your settings as initial description does (or share your settings screenshot) ?

fbaligand avatar Nov 06 '23 07:11 fbaligand