Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: ryehThis has come up a couple times with a few customers, and I thought I'd take a whack at it. The problem goes like this - you have multiple fields that you want to get the min/max/average values of. Often you will do this in an Agg or Agg Ex node with the various group* functions. This is fine, but can be a pretty tedious process. The Quick Stats node actually does a good job of doing this. You specify the fields that you want stats of, and also the stats that you want. The problem with it is that the output is a concatenation of all the fields' stats. That is, if you want the average values of Amt1, Amt2, and Amt3, you will get three records, as opposed to one record with Amt1_avg, Amt2_avg, and Amt3_avg columns.
This example basically takes the results of the Quick Stats output and stitches (via Joins) them together. Because it utilizes the Quick Stats node, you can either specify a list of fields of which you want stats of, or utilize RegEx to choose those fields. This method is definitely not as "efficient" as manually hard-coding it via the Agg Ex node, but should provide a good shortcut for simple cases (and small data volumes).
So as a quick example, say you have the following data:
Group,Amt1,Amt2,Amt3
A,1,0,9
A,2,0,8
A,3,0,7
B,4,1,6
B,5,1,5
B,6,1,4
C,7,2,3
C,8,2,2
C,9,2,1
If you group by the Group field and choose to return the averages for Amt1, Amt2, and Amt3, you will get:
Group,Amt1_avg,Amt2_avg,Amt3_avg
A,2,0,8
B,5,1,5
C,8,2,2
Attachments:
groupStats.brg