Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

AVG?

sum({<Y=,Monthnum=>}Sales)/Count( DISTINCT Monthnum) 

when i am trying calculate it is not giving avg

here Count( DISTINCT Monthnum)  is 06 

if i give manually 06 then it is giving avg    if i write  Count( DISTINCT Monthnum)  its not giving avg

its giving only   sum(sales)  

what is the mistake here ?

4 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

it most likely related with the fact that you are ignoring the MonthNum in you first set analysis,trying creating this in a variable

Anonymous
Not applicable
Author

Is Monthnum a correct field name?  What if you try this in a text box:

Count( DISTINCT Monthnum) 

Not applicable
Author

hi COMMONQLIK

cAN YOU SHARE YOUR SAMPLE FILE?

Not applicable
Author

Hi,

If sum({<Y=,Monthnum=>}Sales)/Count( DISTINCT Monthnum) gives you sum({<Y=,Monthnum=>}Sales) its because Count( DISTINCT Monthnum) = 1.

If Count( DISTINCT Monthnum)=1 its because you have only one monthnum.

Have you selected a month ?

Is Monthnum the correct field ?


Maybe have you forgotten the set analysis in the second aggregation. Try this :

sum({<Y=,Monthnum=>}Sales)/Count({<Y=,Monthnum=>}DISTINCT Monthnum)