2 Replies Latest reply: May 24, 2016 9:50 AM by Mark Graham

# Calculating average in set analysis

(Avg(Aggr(Sum({<[Recent 7 Days] -= {'-'}>}eaches ),[Recent 7 Days]))) /

Avg((Aggr(Sum({<[Recent 7 Days] -= {'-'}>}duration_logged_in_Hrs ),[Recent 7 Days])))

Hi all,

i'm using above script to calculate average of 'eaches' consumed in recent 7 days.

Although it is giving me the average, i do not wanna divide the average eaches in recent 7 days with

average hrs logged in.

I'm trying to divide sum of eaches / sum of logged in hrs. (Still having the condition Recent 7 Days <> '-'

Not working:

(Aggr(Sum({<[Recent 7 Days] -= {'-'}>}eaches ),[Recent 7 Days]))) /

((Aggr(Sum({<[Recent 7 Days] -= {'-'}>}duration_logged_in_Hrs ),[Recent 7 Days])))

Any help is highly appreciated!

• ###### Re: Calculating average in set analysis

Not sure if I understand, but in general, use (outer) aggregation functions

Sum(Aggr(Sum({<[Recent 7 Days] -= {'-'}>}eaches ),[Recent 7 Days]))) /

Sum((Aggr(Sum({<[Recent 7 Days] -= {'-'}>}duration_logged_in_Hrs ),[Recent 7 Days])))

edit: Or maybe you don't need to group by [Recent 7 Days]?

=Sum({<[Recent 7 Days] -= {'-'}>}eaches ) /  Sum({<[Recent 7 Days] -= {'-'}>}duration_logged_in_Hrs )

• ###### Re: Calculating average in set analysis

Thanks a lot swuehl

I learnt a good thing about set analysis