So, something like this should work then: "aggregations":[ { "fieldName":"metric1", "name":"metric1", "type":"longSum" }, { "fieldName":"metric2", "name":"metric2", "type":"longSum" } ], "postAggregations":[ { "name":"result", "fn":"+", "type":"arithmetic", "fields":[ { "fieldName":"metric1", "name":"metric1", "type":"fieldAccess" }, { "fieldName":"metric2", "name":"metric2", "type":"fieldAccess" } ] } ], ... "metric": "result" ... as the config.
On Thu, Oct 11, 2018 at 6:49 PM Charles Allen <charles.al...@snap.com.invalid> wrote: > For the vast majority of use cases, Yes! For example, lets say you have two > metrics "Cost" and "Taxes" as USD cents. When you add the two together you > get the total that was charged (or something similar). > > To get the total that was charged across everything, you simply sum the > Cost and sum the Taxes as aggregators, then do what's called a > post-aggregator to sum those two aggregators. > > The place where this DOESN'T work well is if Cost is is local monies, and > you want to convert every event to USD and then sum them. The easiest way I > know to handle such a thing is to do the conversion during your initial > data cleanup and processing. An example on a similar vein is if you want to > do "inflation adjusted USD". For these two scenarios I'd really have to > think about if there's a clean way to do the calculation; no immediate one > comes to mind. In these scenarios the way I can think of would be: > > A) Do a topN (or groupBy) against the currency type, then do some client > side aggregation to convert the per-currency result into a constant > currency value > B) Do a timeseries, and do the per-time-bucket conversion on the client > side, then do the final aggregation on the client side as well. > > Hopefully that clarifies things a bit. > > > On Thu, Oct 11, 2018 at 6:07 AM Abhishek Kaushik <akaushik...@gmail.com> > wrote: > > > Hi, > > Suppose I have two metrics A and B in my dataset. I need to have a TopN > > query on the aggregated combination of both (here A+B). Is it possible in > > druid? > > >