I'm trying to calculate an average column in a chart by renaming the Total column (created with the addtotals command) and diving it by the number of columns summed by addtotal, but the average will change as new events are added so I wouldn't prefer to simply use the current average, as that would require routinely updating the code. Is there a way to create the average within the eval command so that it would update automatically as new data is added? It would simply require that the Average (formerly Total) column would be divided by a distinct count of one of the categories being analysed.
I won't post all of the code in my search, as, at this point, I've created a chart, transposed it, appended a column, added totals and altered them with eval, and repeated that last step to different effect (I'm quite a way through a dashboard at this point). The last snippet of code which describes the current point is as follows.
| table pWeekInQuarter 1 2 3 4 5 6 7 8 9 10 11 12 13
| addcoltotals labelfield="pWeekInQuarter" label="Average"
| transpose column_name=pWeekInQuarter header_field=pWeekInQuarter 0
| eval "Average"=$Average$/[search index=breakdown | stats dc($pQuarter$)]
In the last line, you can see a subsearch to pull the statistic required for the average. That, however, wouldn't work. It is where that subsearch is, following the slash, that I need to place an actively updated statistic.
... View more