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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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 ?

Labels (1)
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)