Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

bobbygino
New Contributor

Average age in a count expression

I want to calculate  an average age with a count distinct in an expression, need some help . thanks?

9 Replies
agigliotti
Honored Contributor II

Re: Average age in a count expression

maybe this:

Avg( Aggr( Count(Distinct Age), your_dimension) )

bobbygino
New Contributor

Re: Average age in a count expression

Is not working ,  I have a list of persons with different ages

ID  Age

A=45

B=35

C=25

D=56

now I want to calculate the average age of my list

=avg(aggr(ID),AGE)) ???

bobbygino
New Contributor

Re: Average age in a count expression

=avg(aggr(count(ID),AGE)) ???

mark6505
Valued Contributor III

Re: Average age in a count expression

Hi Marc,

I would Try something like the below

SUM(DISTINCT Age) / COUNT(DISTINCT Age)

Mark

agigliotti
Honored Contributor II

Re: Average age in a count expression

maybe this:

Avg( Aggr( Count(Distinct AGE), ID) )

manoj217
Contributor II

Re: Average age in a count expression

this will shows the no of distinct values and finding the avg of that distinct values  not the ages

agigliotti
Honored Contributor II

Re: Average age in a count expression

then simple use the below expression:

Sum(Age)

/

Count(ID)

prithviram777
New Contributor III

Re: Average age in a count expression

Hi

try 

Avg(Aggr(sum( distinct (Age)),Age))

martinpohl
Valued Contributor II

Re: Average age in a count expression

why do you want to use count in your expression?

avg (Agr) returns 40.24 (sum of 161 years devided by 4 ID)

Regards

Community Browser