Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Avg() Function

Hello Guys,

I just want to clarify how Avg() works. The first time I use avg, it is working properly. Giving me the right average like 3.4 or 3.1 etc.

But I have to include a 'historical' data in my application and boom! The avg goes 'gaga' and my output average goes beyond 800+++!

Even if I click year 2013, my average computation is 700! Why did it went like that? How do I find/resolve this problem?

Can you guys give me how it works? Anyone can explain?

Thanks a bunch!

Donna

9 Replies
er_mohit
Master II
Master II

try this

avg({<year={"$(=year)"}>}sales)

here sale is my fieldname.

you just put your fieldname there.

hope it helps

Not applicable
Author

Sorry, still the same output 😞

er_mohit
Master II
Master II

m not sure why it didn't give you right answer. might be there duplicate values use distinct word.

avg(distinct{<year={"$(=year)"}>}sales).

hope it resolve your problem

Not applicable
Author

still nope 😐

b.u.m.p~

Not applicable
Author

sample app pls?

hic
Former Employee
Former Employee

The Avg() function works fine and returns the average per record. If you want the average per something else, e.g. Year you should use Sum(...) / Count(distinct Year)

You most likely have some records that have very large values. Find these by using the Max() function in a chart or in a statistics box.

HIC

Emmanuelle__Bustos
Partner - Specialist
Partner - Specialist

Hi

hic
Former Employee
Former Employee

What do you mean "beyond Logic"? What do you get as result?

Could it be that it just loses the formatting? It so, try TimeStamp(Sum()/Count(distinct )) .

HIC

Emmanuelle__Bustos
Partner - Specialist
Partner - Specialist

Hi Henric

Thanks for response I meant an "unwanted result" sorry my expression I opened a discussion trying to be more specific:

http://community.qlik.com/thread/122140

By the way I read your blog:

Average – Which average?

and tried the Avg( Aggr( Sum(Amount), MonthID ) )

changing the fields for my app fields of course  and the result is the same as with the two formulas in my discussion.