Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
bobbygino
Contributor
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?

10 Replies
agigliotti
MVP
MVP

maybe this:

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

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
bobbygino
Contributor
Contributor
Author

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
Contributor
Contributor
Author

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

Mark_Little
Luminary
Luminary

Hi Marc,

I would Try something like the below

SUM(DISTINCT Age) / COUNT(DISTINCT Age)

Mark

agigliotti
MVP
MVP

maybe this:

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

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
manoj217
Creator III
Creator III

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

agigliotti
MVP
MVP

then simple use the below expression:

Sum(Age)

/

Count(ID)

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
prithviram777
Partner - Contributor III
Partner - Contributor III

Hi

try 

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

martinpohl
Partner - Master
Partner - Master

why do you want to use count in your expression?

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

Regards