
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this
avg({<year={"$(=year)"}>}sales)
here sale is my fieldname.
you just put your fieldname there.
hope it helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, still the same output 😞


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
still nope 😐
b.u.m.p~

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sample app pls?

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi hic
I have an issue like that, when use Avg() function using time value it works fine when selecting one or multiple values but only if they are continuous days i mean selecting 1st to 5th May it the function sends the right Average but if selecting values like 1st to 5th and adding the 7th (excluding 6th) the resulting average is beyond "Logic" i tried to use the time values as time and num value but the results are the same. I can't find a way to make this work, im even using a formula but works the same way:
Avg(HORA_SALIDA_HHC)
or
=SUM(HORA_SALIDA_HHC) / Count(DISTINCT FECHA_HH)
can you gime a hand to understand the wrong result?

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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(HORA_SALIDA_HHC)/Count(distinct FECHA_HH)) .
HIC


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
