Average aggregator

78 views
Skip to first unread message

Kavitha Raghavachar

unread,
Mar 28, 2012, 10:18:40 PM3/28/12
to cascadi...@googlegroups.com
Hi,
I have 200 rows feed and on a particular Field, I want to take an Average. I tried

leadsPipe = new Every(leadsPipe, LEADSS1, new Average(LEADSS1_AVG));

where LEADSS1 is a field I want to take average on and LEADSS1_AVG is a new field where my average computed value will be held.

The above code gives me the Sum of that field. (I verified it by copying the feed to Excel and taking an average on a column)

Please help.
Thanks,
Kavitha

Ben Linsay

unread,
Mar 28, 2012, 10:34:57 PM3/28/12
to cascadi...@googlegroups.com
It sounds like your GroupBy (or CoGroup) isn't working the way you think it is.

Chris K Wensel

unread,
Mar 29, 2012, 1:04:36 AM3/29/12
to cascadi...@googlegroups.com
can we see more code leading up to the Average?

ckw

--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cascading-user/-/Jd6YNL3VKX0J.
To post to this group, send email to cascadi...@googlegroups.com.
To unsubscribe from this group, send email to cascading-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cascading-user?hl=en.


Kavitha Raghavachar

unread,
Mar 29, 2012, 2:11:11 AM3/29/12
to cascadi...@googlegroups.com

Hi Chris,
leadsPipe = new GroupBy(leadsPipe, LEADSS1.append(LEADSS7).append(LEADSS30).append(PAGESS1).append(PAGESS7).append(PAGESS30));

        leadsPipe = new Every(leadsPipe, LEADSS1, new Average(LEADSS1_AVG));

Now the problem is this.

The actual average of all the rows for Field LEADSS1 is
0.061538462 (According to calculation in Excel)

I am getting 0.0 which is rounded to 1 decimal.
How can I format it to show me at least 5 decimals?

Thanks,
Kavitha

On Wednesday, March 28, 2012 10:04:36 PM UTC-7, Chris K Wensel wrote:
can we see more code leading up to the Average?

ckw

On Mar 28, 2012, at 7:18 PM, Kavitha Raghavachar wrote:

Hi,
I have 200 rows feed and on a particular Field, I want to take an Average. I tried

leadsPipe = new Every(leadsPipe, LEADSS1, new Average(LEADSS1_AVG));

where LEADSS1 is a field I want to take average on and LEADSS1_AVG is a new field where my average computed value will be held.

The above code gives me the Sum of that field. (I verified it by copying the feed to Excel and taking an average on a column)

Please help.
Thanks,
Kavitha


--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cascading-user/-/Jd6YNL3VKX0J.
To post to this group, send email to cascading-user@googlegroups.com.
To unsubscribe from this group, send email to cascading-user+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cascading-user?hl=en.

Chris K Wensel

unread,
Mar 29, 2012, 2:29:28 AM3/29/12
to cascadi...@googlegroups.com

Aggregators (like Average) perform over the set of values associated with a unique set of grouping keys, just like the way SQL works.

unfortunately you are including the thing your are averaging in the grouping keys which means all the values of LEADSS1 Average is seeing are probably the same for each unique group.

removing LEADSS1 from the grouping will likely give you a better result.

ckw

To view this discussion on the web visit https://groups.google.com/d/msg/cascading-user/-/9IMLiZp_RrAJ.
To post to this group, send email to cascadi...@googlegroups.com.
To unsubscribe from this group, send email to cascading-use...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cascading-user?hl=en.

Kavitha Raghavachar

unread,
Mar 29, 2012, 2:39:32 AM3/29/12
to cascadi...@googlegroups.com
Thanks Chris.
how about the rounding decimal to show 6 decimals?
Since the actual average is 0.06XXXXX, my result is showing just 0.0 and I want to be able to display up to 6 decimals.

Thanks,
Kavitha

Chris K Wensel

unread,
Mar 29, 2012, 12:04:08 PM3/29/12
to cascadi...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msg/cascading-user/-/DaDOMDeHrAkJ.
To post to this group, send email to cascadi...@googlegroups.com.
To unsubscribe from this group, send email to cascading-use...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/cascading-user?hl=en.
Reply all
Reply to author
Forward
0 new messages