Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

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')

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

4 Replies
OmarBenSalem
Partner
Partner

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')

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

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'))