Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

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

Tags (1)
9 Replies
er_mohit
Honored Contributor II

Re: Avg() Function

try this

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

here sale is my fieldname.

you just put your fieldname there.

hope it helps

Not applicable

Re: Avg() Function

Sorry, still the same output Smiley Sad

er_mohit
Honored Contributor II

Re: Avg() Function

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

Re: Avg() Function

still nope Smiley Indifferent

b.u.m.p~

Not applicable

Re: Avg() Function

sample app pls?

Employee
Employee

Re: Avg() Function

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
Valued Contributor

Re: Avg() Function

Hi

Employee
Employee

Re: Avg() Function

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
Valued Contributor

Re: Avg() Function

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.

Community Browser