Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
jonathanrichey
Contributor III
Contributor III

Set Expression Avg Distinct

Is it possible to calculate an average within a set expression? I would like to calculate the average number of active employees for the current selection.
I am calculating the active EE by =num(COUNT({<PeriodType={'Current'},isActiveEmp_flg={1}>}DISTINCT Employee_Number),'#,##0')
After updating my expression to include Avg, I do not return any results. Is this due to aggregate and non aggregate? 

Capture.PNG

Labels (2)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

If i understand correctly, You can define as 

num(Avg(Aggr(COUNT({<PeriodType={'Current'},isActiveEmp_flg={1}>}DISTINCT Employee_Number),AsOfPeriod)),'#,##0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

4 Replies
OmarBenSalem

How are u calculating the AVG?

 

u can't use 2 agg functions at the same time ; to use the avg, ur expression should be as follow:

 

avg(aggr(count(measure),dimension))

sunny_talwar

What exactly are you hoping to see when using the Avg? Is it a single number across all the AsOfPeriod? and what is the exact expression you have tried?
Anil_Babu_Samineni

If i understand correctly, You can define as 

num(Avg(Aggr(COUNT({<PeriodType={'Current'},isActiveEmp_flg={1}>}DISTINCT Employee_Number),AsOfPeriod)),'#,##0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
jonathanrichey
Contributor III
Contributor III
Author

Thanks for the quick reply!

I was calculating the average by:

avg(num(COUNT({<PeriodType={'Current'},isActiveEmp_flg={1}>}DISTINCT Employee_Number),'#,##0'))