# QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for
Did you mean:
Contributor

## avg Age

Hi Community,

we got the task to calculate the avg age of our customers in a table regarding ad hoc dimension and dynamic time-periods.

now we have to calulate in these steps:

1.We have the age of a single customer per order :

customer1: 49+50+50 (men)

customer2: 32+32  (men)

customer3: 43+43+44 (women)

We put our dimensions-selections in following ad-hoc dimension:

vSelectedDim = GetFieldSelections(_dimensionname)

2. Then we want to aggratage this age for the selected timeperiod and ad hoc-dimensions:

customer1: (49+50+50)/3 =      49,67

customer2: (32+32)/2 =          32,0

customer3: (43+43+44)/3 =      43,33

what works for us is:
vAge
= 'aggr(avg([Age]),Customer, Order, '&\$(vSelectedDim)&')'

3. At last we want to get the average-age of all customers, who bought in the selected time period, separeted by gender:

men: Ø Age = (49,67+32)/2 = 40,83 years

women: Ø Age = (43,33)/1 = 43,33 years

Do you have an idea, how to get the last step?

Thanks a lot,
Katalina and Nina